#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j = 2, k, n, l;
  cin >> n >> l;
  k = n;
  if (n == l)
    cout << "YES" << endl << 0 << endl;
  else {
    for (i = 1;; i++) {
      n = n * k;
      if (n == l) {
        cout << "YES" << endl << i << endl;
        break;
      } else if (n > l) {
        cout << "NO" << endl;
        break;
      }
    }
  }
}
