#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, l, counter = 0;
  cin >> k >> l;
  long long ans = k;
  while (ans < l) {
    ans *= k;
    counter++;
  }
  if (ans == l) {
    cout << "YES" << endl << counter;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
