#include <bits/stdc++.h>
using namespace std;
int in() {
  int n;
  scanf("%d", &n);
  return n;
}
long long Lin() {
  long long n;
  scanf("%lld", &n);
  return n;
}
double Din() {
  double n;
  scanf("%lf", &n);
  return n;
}
const double gama = 0.57721566490;
const double eps = 0.00000001;
const long long inf = 1e17;
const long long mod = 1e9 + 7;
const int N = 2e5 + 5;
int cal(int n) { return (n * (n + 1)) / 2; }
int main() {
  int l = in(), k = in();
  int ans = -1;
  while (k % l == 0) k /= l, ans++;
  if (k == 1)
    printf("YES\n%d\n", ans);
  else
    printf("NO\n");
  return 0;
}
