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