#include <bits/stdc++.h>
using namespace std;
long long eleva(int a, int n) {
  long long resp = 1;
  for (int i = 1; i <= n; i++) resp *= a;
  return resp;
}
int x, y;
void solve() {
  if (x == y) {
    cout << "YES" << endl;
    cout << "0" << endl;
    return;
  }
  int aux = 1, flag = 0;
  while (true) {
    if (y == eleva(x, aux + 1)) {
      flag = 1;
      break;
    } else if (y < eleva(x, aux + 1))
      break;
    aux++;
  }
  if (flag) {
    cout << "YES" << endl;
    cout << aux << endl;
  } else
    cout << "NO" << endl;
}
int main() {
  cin >> x >> y;
  solve();
  return 0;
}
