#include <bits/stdc++.h>
using namespace std;
void help() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  help();
  unsigned long long k, l;
  cin >> k >> l;
  if (k > l) {
    cout << "NO";
    return 0;
  } else if (k == l) {
    cout << "YES" << endl << "0";
    return 0;
  } else if (l % k != 0) {
    cout << "NO";
    return 0;
  } else {
    int counter = 0;
    unsigned long long temp = k;
    while (k < l) {
      k *= temp;
      counter++;
    }
    if (pow(temp, counter + 1) == l)
      cout << "YES" << endl << counter;
    else
      cout << "NO";
    return 0;
  }
}
