#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <utility>
#include <cstdarg>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define space char(32)
#define line char(10)
#define debug(x) cerr << '[' << #x << " = " << x << ']' << line
#define speedup ios_base::sync_with_stdio(false); cin.tie(NULL)
#define output_array(arr) for(auto &i: arr) cout << i << line
#define input_array(arr) for(auto &i: arr) cin >> i
#define For(n) for(int i = 0; i < n; i++)
#define hell 1000000007

typedef long long ll;

using namespace std;

int main()
{
	speedup;

	ll str, y, a, b, exp = 0;
	
	cin >> str >> y >> a >> b;
	
	while(str < y){
		if(str <= (str + b) / a) // && str * a < LLONG_MAX)
			str *= a;
		else
			break;
		++exp;
		// debug(str);
	}
	
	if(str >= y){
		--exp;
	}
	else{
		ll temp;
		temp = (y - str) / b;
		
		str += temp * b;

		exp += temp;
		
		if(str == y)
			exp--;
	}
	
	cout << exp << line;
	
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n);i++)
using ll = long long;
const ll INF = 1e9+7;
const ll mod=1000000007;
using P = pair<ll, ll>;

ll x, y, a, b;
int main(){
    cin >> x >> y >> a >> b;

    ll ans2 = 0;
    while((double)a*x< y && a*x < x+b){
        x *= a;
        ans2++;
    }
    ans2 += (y-x-1)/b;
    cout  << ans2 << endl;
}

