#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, a[105], cnt = 0, i;     fill_n(a, 105, 0);     for (cin >> m >> n; n; n /= m) a[cnt++] = n % m;     if (cnt > 100) {       cout <<  NO ;       return 0;     }     for (i = 0; i < 105; ++i) {       if (a[i] <= 1)         continue;       else if (a[i] < m - 1) {         cout <<  NO ;         return 0;       } else         ++a[i + 1];     }     cout <<  YES ;   }   