#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, res = 0;
  bool ok = 0;
  cin >> a >> b;
  if (a > b) {
    cout << "NO";
    return 0;
  }
  while (1) {
    b /= a;
    res++;
    if (b == 1) break;
    if (b != ceil(b)) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "NO";
  } else {
    cout << "YES\n" << res - 1;
  }
  return 0;
}
