#include <bits/stdc++.h>
using namespace std;
int main() {
  bool ok = false;
  unsigned long long k, l, count = 0, z;
  cin >> k >> l;
  z = k;
  while (k <= l) {
    if (k == l) {
      cout << "YES" << endl;
      cout << count << endl;
      ok = true;
      break;
    }
    k = k * z;
    count++;
  }
  if (!ok) cout << "NO" << endl;
  return 0;
}
