#include <bits/stdc++.h>
using namespace std;
long long int expo(int num, int p) {
  if (p == 0) {
    return 1;
  } else if (p % 2 == 0) {
    long long int c = expo(num, p / 2);
    return c * c;
  }
  return num * expo(num, p - 1);
}
int main() {
  long long int n, t, count = -1;
  cin >> n >> t;
  while (t % n == 0) {
    t /= n;
    count++;
  }
  if (count >= 0 && t == 1) {
    cout << "YES"
         << "\n";
    cout << count << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
