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