#include<bits/stdc++.h>

using namespace std;

#define int long long
const int mod=998244353;

signed main()
{
  	
  	int a,b,c;
  
  	cin>>a>>b>>c;
  	
  	int x=(a*(a+1))/2;
  	x%=mod;
  	
  	int y=(b*(b+1))/2;
  	y%=mod;
  	
  	int z=(c*(c+1))/2;
  	z%=mod;
  	 
  	int ans= ( ((x*y)%mod) * z)%mod;
  	cout<<ans<<"\n";
  	
  	return 0;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}
#ifdef LOCAL
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cerr<<(*i)<<" ";cerr<<endl;}
#else
template<class T>void pv(T a,T b){}
#endif

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll X = nextLong();
  ll Y = nextLong();
  ll A = nextLong();
  ll B = nextLong();

  ll ans = 0;
  for (ll a = 0; a <= 70; a++) {
    ll x = X;
    bool ok = true;
    REP(i, a) {
      if (x * A < Y && x < Y / A) {
        x *= A;
      } else {
        ok = false;
      }
    }
    if (!ok) continue;
    ll b = (Y - 1 - x) / B;
    ll val = a + b;
    chmax(ans, val);
  }

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}
