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