#include<bits/stdc++.h>
#define lli unsigned long long int 
#define endl "\n"
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
using namespace std;
lli min(lli a,lli b)
{
    if (a<b)
    {
        return a;
    }
    else
    {
        return b;
    }    
}
lli max(lli a,lli b)
{
    if (a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}

void solve()
{
    lli x,y,a,b;
    cin>>x>>y>>a>>b;
    lli cnt=0;
    while((__int128)x*a<y && x*a<=x+b )
    {
        x*=a;
        cnt++;
    }
  
    cnt+=(y-x-1)/b;
     
     
    cout<<cnt<<endl;
  
}


int main(){
    
    fastio;
    cout<<fixed;
    cout<<setprecision(10);
    lli t=1;
//    cin>>t;
    for(lli i=1;i<=t;i++)
    {
        solve();
    }
    return 0;  
}
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 100005
#define mid(l,r) l+(r-l)/2
#define removeduplicates(vec) vec.erase( unique( vec.begin(), vec.end() ), vec.end() )
#define memset1(v) memset(v,-1,sizeof(v))
#define memset0(v) memset(v,0,sizeof(v))
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll x,y,a,b;
	ll c=0;
	cin>>x>>y>>a>>b;
	ll maxi=0;
	while(1){
		ll rem=y-x;
		maxi=max(maxi,c+rem/b+(rem%b!=0));
		c++;
		if(x>=y/a)break;
		x*=a;
	}
	maxi=max(maxi,c);
	cout<<maxi-1;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}