#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int main() {
  long long k, l, q = 0, w = 1;
  cin >> k >> l;
  if (k == l) {
    cout << "YES\n0";
    return 0;
  }
  if (k > l) {
    cout << "NO";
    return 0;
  }
  while (l > w) {
    q++;
    w *= k;
  }
  if (l == w) {
    cout << "YES\n" << q - 1;
    return 0;
  }
  cout << "NO";
  return 0;
}
