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