#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c = 0;
  cin >> n >> k;
  while (k > n) {
    c++;
    if (k % n == 0)
      k = k / n;
    else {
      k = 0;
      break;
    }
  }
  if (k == n)
    cout << "YES" << endl << c;
  else
    cout << "NO";
  return 0;
}
