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