#include <bits/stdc++.h>
using namespace std;
long long int x[1000007], y[1000007], z[1000007], n;
string s, S;
int main() {
  long long int a, b, c = 0, d, diff, e, f, g, i, j, k, l, m, in, mod, loc, p,
                      q, r, u, val, w, t, tc, sz, lo, hi, mid, mn = 2134567891,
                      mx = 0, sum = 0, ans = 0;
  cin >> a >> b;
  p = 1;
  while (p < b) {
    p *= a;
    c++;
  }
  if (p == b)
    cout << "YES\n" << c - 1 << endl;
  else
    cout << "NO\n";
  return 0;
}
