#include <bits/stdc++.h>
using namespace std;
int ind[100001];
int main() {
  int n, m;
  cin >> n >> m;
  int c = 0;
  while (m % n == 0) {
    if (m == n) {
      cout << "YES\n" << c << "\n";
      return 0;
    }
    m /= n;
    c++;
  }
  cout << "NO\n";
}
