#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, l;
  cin >> k >> l;
  int pro = 1, cnt = 0;
  bool flag = true;
  if (l % k == 0) {
    for (int i = 0; i < 40; i++) {
      pro = pro * k;
      if (pro == l) {
        cout << "YES" << endl;
        cout << cnt << endl;
        flag = false;
        break;
      } else
        cnt++;
    }
    if (flag != false) cout << "NO" << endl;
  } else
    cout << "NO" << endl;
}
