#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  bool z = false;
  cin >> x;
  cin >> y;
  int i = x, j = 0;
  while (i <= y && !z && y % i == 0) {
    if (i == y) {
      z = true;
    } else {
      i = i * x;
      j++;
    }
  }
  if (z) {
    cout << "YES"
         << "\n";
    cout << j;
  } else {
    cout << "NO"
         << "\n";
  }
  return 0;
};
