#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, k, l, t, ans = 0;
  cin >> k >> l;
  t = k;
  while (t <= l) {
    if (t == l) {
      cout << "YES\n" << ans;
      break;
    }
    t = t * k;
    ans = ans + 1;
  }
  if (t != l) {
    cout << "NO\n";
  }
  return 0;
}
