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

ll x,y,a,b;

void solve()
{
	ll ans = 0;
	while(x<y && x<=(b/(a-1))){
        x*=a;
        ans++;
	}
	if(x>=y){
		cout<<ans-1<<'\n';
		return;
	}
	ans+=(y-x)/b;
	if((y-x)%b == 0) ans--;
	cout<<ans<<'\n';
}

int main()
{
	cin >> x >> y >> a >> b;
	solve();
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

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

    // a 倍 x -> ax dif = (a - 1) * x
    // y / x
    ll res = 0;
    while (1) {
        if (a > y / x + 10) break;
        if ((a - 1) * x <= b) x *= a;
        else break;
        if (x >= y) break;
        res++;
    }
    if (x < y) res += (y - x - 1) / b;
    cout << res << endl;
    return 0;
}