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