#include <bits/stdc++.h>
int main() {
  int i, ans = 0;
  long long k, L, t;
  scanf("%I64d%I64d", &k, &L);
  t = k;
  while (t <= L) {
    if (t == L) {
      printf("YES\n%d\n", ans);
      break;
    }
    t = t * k;
    ans += 1;
  }
  if (t != L) printf("NO\n");
  return 0;
}
