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

int main(){
    long long X,Y,A,B,T,K=0;
    cin >> X >> Y >> A >> B;
    T=X;
    while(true){
        if(T>=Y/A){
            break;
        }
        if(T*A>=Y){
            break;
        }
        if(T*A<T+B){
            K++;
            T*=A;
        }
        else{
            break;
        }
    }
    long long add=(Y-1-T)/B;
    cout << K+add << endl;
}
#include<bits/stdc++.h>
using namespace std;

/***typededfs***/
typedef long long ll;
typedef long double ldb;

/***defines***/
#define M1 1000000007
#define M2 998244353
#define F first
#define S second
#define pb push_back
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forz(i,n) for(int i=0;i<(n);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define rforz(i,n) for(int i=(n-1);i>=0;i--)
#define rfore(i,a,b) for(int i=(a);i>=(b);i--)
#define test int T; cin>>T; while(T--)
#define all(v) v.begin(),v.end()
#define mm(a,b) ((a%M1)*(b%M1))%M1
#define ma(a,b) ((a%M1)+(b%M1))%M1

void io(){
    FASTIO;
    #ifndef ONLINE_JUDGE
  	freopen("input.txt","r",stdin);
  	freopen("output.txt","w",stdout);
    #endif
}


int main(){
    io();
    ll x,y,a,b;
    cin>>x>>y>>a>>b;
    ll cnt{};
    while(x<=(b-1)/a&&x*a<y){
        x*=a;
        cnt++;
    }
    if(y-x-1>=0)
    cnt+=(y-x-1)/b;
    cout<<cnt<<'\n';
}