#include <bits/stdc++.h>
using namespace std;
int a[14] = {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777};
int main() {
  long long n, m, i, j, k, l, s = 0;
  cin >> k >> l;
  while (l >= k) {
    if (l % k == 0) {
      l /= k;
      s++;
    } else {
      printf("NO");
      return 0;
    }
  }
  if (l == 1) {
    printf("YES\n");
    cout << s - 1;
  } else
    printf("NO");
  return 0;
}
