#include <bits/stdc++.h>
using namespace std;
long long a, b, n;
short ans = 0;
int main() {
  cin >> a >> b;
  while (b > 0) {
    if (b == 1) {
      ans = 0;
      break;
    }
    if (b % a != 0) {
      ans = 1;
      break;
    }
    ++n;
    b = b / a;
  }
  if (ans == 0) {
    cout << "YES" << endl;
    cout << n - 1;
  } else
    cout << "NO" << endl;
}
