#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 5;
long long poww(long long a, long long n) {
  if (n == 0) return 1;
  if (n == 1) return a % 1000000007;
  long long v = poww(a, n / 2);
  v = (v * v) % 1000000007;
  if (n % 2 == 1) return (v * a) % 1000000007;
  return v % 1000000007;
}
inline void getInt(int& x) {
  int c = getchar();
  x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
inline void out_d(int n) {
  if (n < 0) {
    n = -n;
    putchar('-');
  }
  int i = 10;
  char output_buffer[10];
  do {
    output_buffer[--i] = (n % 10) + '0';
    n /= 10;
  } while (n);
  do {
    putchar(output_buffer[i]);
  } while (++i < 10);
  putchar(' ');
}
priority_queue<pair<long long, long long> > q;
int main() {
  ios::sync_with_stdio(false);
  long long l, k, ans = 0;
  cin >> l >> k;
  long long p = l;
  while (l < k) {
    l *= p;
    ans++;
  }
  if (l == k)
    cout << "YES\n" << ans;
  else
    cout << "NO";
  return 0;
}
