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