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