#include <bits/stdc++.h>
long long k, l, temp, importance = 0;
int main() {
  scanf("%I64d %I64d", &k, &l);
  temp = k;
  while (temp < l) {
    temp *= k;
    importance++;
  }
  if (temp == l)
    printf("YES\n%I64d\n", importance);
  else
    printf("NO\n");
  return 0;
}
