#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, l;
  cin >> k;
  cin >> l;
  long long int p = 0, c = 0;
  if (l % k == 0) {
    long long int x = l / k;
    while (x > 1) {
      if (x % k == 0) {
        c++;
        x = x / k;
      } else {
        cout << "NO";
        p = 1;
        break;
      }
    }
    if (p != 1) {
      cout << "YES" << endl;
      cout << c;
    }
  } else {
    cout << "NO";
  }
}
