#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> comp;
  int n;
  cin >> n;
  int v;
  cin >> v;
  long long s = 1;
  int c = 0;
  int ok = 0;
  if (n == v) {
    cout << "YES\n";
    cout << 0;
    return 0;
  }
  for (int i = n; i <= pow(2, 20); i++) {
    s *= n;
    c++;
    if (s == v) {
      ok = 1;
      break;
    }
  }
  if (ok) {
    cout << "YES\n";
    cout << c - 1;
  } else {
    cout << "NO";
  }
}
