/**
 * @author: adityasonani
 * */
#include <bits/stdc++.h>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define     ll          long long
#define     ld        	long double
#define     ln          "\n"
#define     fastio      ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define     MOD         (int) 1000000007
#define     rep(i, n)   for (int i = 0; i < (int)n; i++)
#define     all(x)      (x).begin(), (x).end()
#define     debug(x)    cerr << #x << " = " << x << endl;
#define     debugV(x)   cerr << "["; for(auto i: x){ cerr << i << ", ";} cerr << "]" << endl;
#define     precise(x)  cout << fixed << setprecision(x)
#define     MAX         (int) 100007 // 10^5
std::vector<int> gv(int n){std::vector<int> v(n);for(auto &x: v){std::cin>>x;}return v;}


using namespace std;

/*
*/

void solve()
{
    vector<int> v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(all(v));

    if((v[2]+v[0])==2*v[1]){
        cout << "Yes";
    }
    else cout << "No";
    
}

signed main()
{
    fastio;

    auto start = std::chrono::high_resolution_clock::now();

    int t=1;
    // cin>>t;

    while(t--)
        solve();
    
 
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);

    // cerr << "\nTime taken : " << ((long double)duration.count())/((long double) 1e9) <<" s "<< endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string X; cin >> X;
  int64_t M; cin >> M;
  if (X.size() == 1) {
    if (stoll(X) > M) {
      cout << 0 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  int64_t maxi = 0;
  rep(i, X.size()) if (maxi < stoi(string(1, X.at(i)))) {
    maxi = stoi(string(1, X.at(i)));
  }
  int64_t ans = (int64_t)pow(M / stoi(string(1, X.at(0))), 1 / (double)(X.size() - 1));
  ans = max(maxi, ans - 1);
  while (true) {
    int64_t temp = 0;
    rep(i, X.size()) {
      if (temp != 0 && temp >= LLONG_MAX / ans) goto BREAK;
      temp = temp * ans + stoi(string(1, X.at(i)));
    }
    if (temp > M) goto BREAK;
    ans++;
  }
BREAK:
  ans = max((int64_t)0, ans - maxi - 1);
  cout << ans << endl;
}