#include <bits/stdc++.h>
int main() {
  int n, m, p = 0;
  long long x;
  scanf("%d%d", &n, &m);
  x = (long long)n;
  while (x < m) {
    x *= (long long)n;
    ++p;
  }
  if (x == m)
    printf("YES\n%d\n", p);
  else
    printf("NO\n");
  return 0;
}
