#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<iterator>
#include<string>
#include<sstream>
#include <unordered_map>
#include<cmath>
using namespace std;
#define ll long long
int __gcd(int a,int b){return b==0 ? a : __gcd(b,a%b);}
ll __gcd(ll a,ll b){return b==0 ? a : __gcd(b,a%b);}
void scan(__int128 &x)//输入
{
    x = 0;
    int f = 1;
    char ch;
    if((ch = getchar()) == '-') f = -f;
    else x = x*10 + ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        x = x*10 + ch-'0';
    x *= f;
}

void print(__int128 x)//输出
{
    if(x < 0)
    {
        x = -x;
        putchar('-');
    }
     if(x > 9) print(x/10);
    putchar(x%10 + '0');
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int _=1;
    while(_--){
        __int128 x,y,a,b; scan(x); scan(y); scan(a); scan(b);
        __int128 ans=0,cnt=0;
        //ll x,y,a,b; cin>>x>>y>>a>>b;
        //ll ans=0,cnt=0;
        while(1){
            if(x>=y) break;
            ans=max(ans,cnt+(y-1-x)/b);
            x*=a; ++cnt;
        }
        print(ans);
        cout<<"\n";
        //cout<<ans<<"\n";
    }
}
#include <bits/stdc++.h>
using namespace std;
#define int long long

using ld=long double;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int x,y,a,b;
    cin >> x >> y >> a >> b;
    int ans=0;
    while(x*a<=x+b and (ld)x*a+1e-8<(ld)y){
    	x*=a,ans++;
    }
    ans+=(y-1-x)/b;
    cout << ans;
}