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