#include using namespace std; int main() { int A,B; cin >> A >> B; int tmp = B/A; int tmp2 = 1; if(A == 1 && B != 1) { cout << "No" << endl; return 0; } for(int i = 0; i < tmp; i++) { tmp2 *= A; if(tmp2 > B) { break; } } if(tmp2 == B) { cout << "Yes" << endl; } else { cout << "No" << endl; } }