#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  double x = log(m) / log(n);
  int jj = (int)(x + 1e-12);
  if (abs(jj - x) < 1e-12)
    cout << "YES"
         << "\n"
         << x - 1;
  else
    cout << "NO";
}
