#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <numeric>
#define REP(i, n, s) for (int i = (s); i < (int)(n); i++)
#define REP0(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
using namespace std;

ll i, j;
const int MOD = 1000000000 + 7;
const int MOD2 = 998244353;

// modint: mod 計算を int を扱うように扱える構造体
template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

using mint = Fp<MOD2>;

struct UnionFind
{
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N)
    {
        r = vector<int>(N, -1);
    }

    int root(int x)
    {
        if (r[x] < 0)
            return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y)
    {
        x--;
        y--;
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (r[x] > r[y])
            swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x)
    {
        return -r[root(x)];
    }

    void show()
    {
        REP0(i, r.size())
        {
            cout<<r[i]<<" ";
        }
        cout<<"\n";
    }
};

int main()
{
    ll x, y, a, b;
    ll ans = 0;

    cin >> x >> y >> a >> b;

    ll kako = x;

    while((double)kako * a <= 2e18 && kako * a <= kako + b && kako * a < y){
        kako *= a;
        ans++;
    }
    ans += max(0LL,(y-kako-1)/b);
    
    cout << ans << '\n';
    return 0;

}
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll x, y, a, b;

int main()
{
	ll ans = 0;
   	cin>>x>>y>>a>>b;
	while (1) {
		if ((1.0 * a - 1) >= (1.0 * b / x))break;
		x = a * x;
		if (x >= y)break;
		ans ++;
	}
	ll cnt = max((ll)0, (y - x - 1)) / b;
	
	printf("%lld\n", ans + cnt);
   	return 0;
}