#include <bits/stdc++.h>
using namespace std;

using ll = long long;

pair<ll, ll> num(string S) {
  const int L = S.size();
  const string lf = S.substr(0, L - 5);
  const string rg = S.substr(L - 4, 4);
  return make_pair(stoll(lf + rg), 10000);
}

map<ll, ll> fac(ll n) {
  map<ll, ll> ret;
  for(ll p = 2; p * p <= n; p++) {
    while(n % p == 0) {
      n /= p;
      ret[p]++;
    }
  }
  if(n > 1) ret[n]++;
  return ret;
}

int main() {
  string A, B;
  cin >> A >> B;
  auto [x, y] = num(A);
  auto [z, w] = num(B);
  if(x == 10000 || z == 0) {
    cout << "Yes" << endl;
  }
  else {
    if(z < 0) {
      swap(x, y);
      z = abs(z);
    }
    auto fx = fac(x);
    auto fy = fac(y);
    for(auto &[p, e] : fy) {
      fx[p] -= e;
      if(fx[p] < 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    for(auto &[p, e] : fx) {
      e *= z;
      if(e % w != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}