#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long a, b;
int main() {
  cin >> a >> b;
  long long x = 1;
  int ans = 0;
  while (x < b) {
    x *= a;
    ans++;
  }
  if (x == b)
    cout << "YES" << endl << ans - 1;
  else
    puts("NO");
  return 0;
}
