#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

ll x, y, a, b;

bool isOverflow(ll x, ll a) {
	return (ll)1e18/x < a;
}

int main() {
	cin >> x >> y >> a >> b;
	ll ans = 0;
	while (1) {
		// cout << x << "\n";
		// cout << ans << "\n";
		if (isOverflow(x,a) || x*a >= x+b) {
			if (x+b >= y) {
				cout << ans << "\n";
				return 0;
			}
			else {
				ans += (y-x-1)/b;
				cout << ans << "\n";
				return 0;
			}
		}
		else {
			if (x*a >= y) {
				cout << ans << "\n";
				return 0;
			}
			else {
				x *= a;
				ans++;
			}
		}
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>

ll myproduct(ll x, ll y)
{
    return (__LONG_LONG_MAX__ / x < y) ? __LONG_LONG_MAX__ : x * y;
}

ll mysum(ll x, ll y)
{
    return (__LONG_LONG_MAX__ - x < y) ? __LONG_LONG_MAX__ : x + y;
}


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

    ll result = 0; //exp
    while(true)
    {
        ll method1 = myproduct(X, A);
        ll method2 = mysum(X, B);

        if(method1 >= Y && method2 >= Y)
        {
            break;
        }
        else if(method1 > method2)
        {
            //continue to choose method2(Atcoder gym)
            result += (Y - X - 1) / B;
            break;
        }
        else
        {
            X = method1;
            result++;
        }
    }
    OUTX(result);


    return 0;
}
