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