#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int main() {
  unsigned long long k, l, cur = 1;
  cin >> k >> l;
  int p = 0;
  for (; cur < l; p++) cur *= k;
  if (cur != l)
    puts("NO");
  else {
    puts("YES");
    printf("%d\n", p - 1);
  }
  return 0;
}
