#include <bits/stdc++.h>
using namespace std;
long long int solve() {
  long long int k, l;
  cin >> k >> l;
  long long int c = 0;
  long long int p = k;
  bool x = false;
  while (p <= l) {
    if (p == l) {
      x = true;
      break;
    }
    p *= k;
    c++;
  }
  if (x) {
    cout << "YES" << endl;
    return cout << c << endl, 0;
  } else
    return cout << "NO" << endl, 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int tests = 1;
  while (tests--) solve();
  return 0;
}
