#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, sum;
  int ans = 0;
  while (cin >> a >> b) {
    sum = a;
    while (sum < b) {
      sum = sum * a;
      ans++;
    }
    if (sum == b)
      cout << "YES" << endl << ans << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
