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