#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, s, dem = 0;
  scanf("%lld%lld", &n, &k);
  s = n;
  while (n < k) {
    n *= s;
    dem++;
  }
  if (n == k) {
    printf("YES\n");
    printf("%lld", dem);
  } else {
    printf("NO");
  }
  return 0;
}
