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