#include <bits/stdc++.h>
using namespace std;
int main() {
	long long x, y, a, b;
	cin >> x >> y >> a >> b;
	long long ans = 0;
	long long tmp = x;
	while (1) {
		if (tmp >= (y / a))break;
        if (tmp * a >= (long long) 2e18)break;
		if (tmp * (a - 1) > b)break;
		ans++;
		tmp *= a;
	}
	ans += (y - tmp -1) / b;
	cout << ans << endl;
	return 0;
}
#include <iostream>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#define flush fflush(stdout)
#define endl '\n'
#define all(v) v.begin(), v.end()
#define pf(dans) printf("%.12lf", dans)
#define pfn(dans) pf(dans); cout << endl;
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod1 = (int)1e9 + 7, mod2 = (int)998244353;
const int INF = (int)1e9 + 10;
const ll LINF = (ll)1e18 + 10;
const int di[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dj[8] = {0, 1, 0, -1, -1, 1, -1, 1};

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)
#define reprev(i, n) for (i = n - 1; i >= 0; i--)

template <typename T>
T my_abs(T x){
    return (x >= 0)? x : -x;
}

template <typename T>
void chmax(T &a, T b){
    a = max(a, b);
}

template <typename T>
void chmin(T &a, T b){
    a = min(a, b);
}

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

bool incld_bit(ll bit, int i){
    return ((bit>>i) & 1) == 1;
}

// --------------------------------------------------------------------------------

int main(void){
    int i, j;
    int a, b, c;

    cin >> a >> b >> c;

    cout << a + b + c - min({a, b, c}) << endl;

    return 0;
}