#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k;
  cin >> k;
  int n;
  cin >> n;
  if (k > n) {
    cout << "NO\n";
  } else {
    int flag = 0, count = 0;
    for (long long i = k; i <= n; i = i * k) {
      count++;
      if (i == n) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      cout << "YES\n";
      cout << count - 1 << "\n";
    } else
      cout << "NO\n";
  }
  return 0;
}
