#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int k, n;
  cin >> k >> n;
  int res = 0;
  while (n % k == 0) {
    n /= k;
    res++;
  }
  if (n != 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl << res - 1 << endl;
  return 0;
}
