#include <iostream>
#include <string>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (a % b == 0) {
cout << "YES" << endl;
}
else {
string A = to_string(a);
string B = to_string(b);
if (A.find(B) != string::npos) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}