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