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