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