#include <bits/stdc++.h>
int main() {
  long long a, b, c, d = 0;
  scanf("%I64d %I64d", &a, &b);
  c = a;
  while (c < b) {
    c = c * a;
    d++;
  }
  if (c == b)
    printf("YES\n%I64d\n", d);
  else
    printf("NO");
}
