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