#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;
ll x,y,a,b,res;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

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

ll cnt=0;

while((double)a*x<=2e18 && x*a<=x+b  && x*a<y)
{
  x=x*a;
  cnt++;
}

res=((y-x-1)/b);

res=res+cnt;

cout<<res<<endl;





return 0;

}



#include <iostream>
#include <algorithm>
#include <vector>

#define int long long

using namespace std;

int32_t main() {
	ios::sync_with_stdio(false);
	int a[4];
	cin >> a[1] >> a[2] >> a[3];
	sort(a + 1, a + 1 + 3);
	if(a[1] == a[2] && a[1] != a[3]) cout << a[3];
	else if(a[2] == a[1] && a[2] == a[3]) cout << a[3];
	else if(a[2] == a[3] && a[1] != a[2]) cout << a[1];
	else cout << 0;
}