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