#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define debarrall(arr) debarr(arr,arr.size())
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

int powersimple(int a, int b){//a^b
    int res=1;
    while(b>0){
        if(b&1)
		{res=(res*a);
		b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

int ncr(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}


int power(int x,int y,int p) 
{ 
    int res = 1;  
    x = x % p;   
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;  
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 

int modInverse(int n, int p) 
{ 
    return power(n, p - 2, p); 
} 

int ncrModPFermat(int n,int r, int p) 
{ 

    if (r == 0) 
		return 1; 
    
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 

int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

///////////////END OF TEMPLATE//////////////////


void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	int x,y,a,b;
	long double r;
	cin>>x>>y>>a>>b;
	m=b/(a-1);
	if(y<=m)
	{
	    cnt=((y-1));
	    r=log(cnt/x)/log(a);
	    while((r-1)>=0)
	    {
	        sum++;
	        x*=a;
	        r-=1;
	    }
	    cout<<sum;
	    return;
	}
	//sum=((m)/x)/a;
	cnt=(m);
	r=log(cnt/x)/log(a);
	    while((r-1)>=0)
	    {
	        sum++;
	        x*=a;
	        r-=1;
	    }
	//x=sum*a*x;
	//if(x<m and x*a<y)
	{
	//    sum++;
	 //   x*=a;
	}
	sum+=(y-1-x)/b;
	cout<<sum;
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(15);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  







#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll X, Y, A, B;
    cin >> X >> Y >> A >> B;

    ll L = B / (A-1);
    //if(B % (A-1) == 0)
    //    L--;

    ll ans = 0;

    while(L >= X){
        if(X*A >= Y)
            break;
        X *= A;
        ans++;
    }

    ll d = Y-1 - X;
    ll n = d / B;
    ans += n;
    X = X + n*B;


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