#include <stdio.h>int main (void){ int n,k,decide=0; scanf("%d %d",&n,&k); if(n%k==0) decide++; while(n){ if(n%10==k) decide++; n/=10; } if(decide) printf("YES"); else printf("NO"); return 0;}