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