#include <bits/stdc++.h>
using namespace std;
long long power(long long k, long long i) {
  long long r = 1;
  while (i--) r *= k;
  return r;
}
int main() {
  long long k, l;
  cin >> k >> l;
  for (long long i = 1; i <= 31; i++) {
    long long g = i;
    if (power(k, i) == l) {
      cout << "YES\n" << g - 1;
      goto e;
    }
  }
  cout << "NO";
e:
  return 0;
}
