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