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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll x,y,a,b;
    cin>>x>>y>>a>>b;

 	ll mn=min(y-1,x+b),ans=0;  
    
    while((__int128)x*a <= (__int128)mn)
    {
    	x*=a;
    	ans++;
    }

    ans+=(y-1-x)/b;
    cout<<ans<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long

const int mod2 = 998244353;
const int mod = 1e9+7;
const int maxi = 4e3 + 2;
int power(int a,int b){
    int res = 1;
    while(b){
        if(b&1LL)res = (res*a)%mod;
        a = (a*a)%mod;
        b/=2LL;
    }
    return res;
}

int fermat(int a){
    return power(a,mod-2);
}

struct seg_tree{    
    int n;
    vector<int> tree;
   
    seg_tree(int _n){
        n = _n;
        n *= 4;
        n ++;
        tree = vector<int>(n,-1);
    }

    void build(int v,int tl,int tr,vector<int> &a){
        if(tl == tr){
            tree[v] = a[tl];
            return;
        }
        int mid = (tl+tr)/2;
        build(v*2,tl,mid,a);
        build(v*2+1,mid+1,tr,a);
        tree[v] = max(tree[v*2],tree[v*2+1]);
    }

    int query(int v,int tl,int tr,int l,int r){
        // cout<<l<<" "<<r<<" "<<tl<<" "<<tr<<" "<<v<<" "<<tree[v]<<endl;
        if(l>r)return -1;
        if((l == tl) && (r == tr))return tree[v];
        int mid = (tl+tr)/2;
        int ans1 = query(v*2,tl,mid,l,min(r,mid));
        int ans2 = query(v*2+1,mid+1,tr,max(l,mid+1),r);
        return max(ans1,ans2);
    }
};

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int T = 1;
    // cin >> T;

    while(T --){        
       int a,b,c;
       cin >> a >> b >> c;
       int s = 21 - (a+b+c);
       cout<<s;
    }

    return 0;
}


 