
// Problem : D - Takahashi Unevolved
// Contest : AtCoder - AtCoder Beginner Contest 180
// URL : https://atcoder.jp/contests/abc180/tasks/abc180_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
vector<ll> fac;
ll nCr2(ll n,ll r,ll m){if(r>n) return 0;return (((fac[n]*power(fac[r],m-2,m))%m)*power(fac[n-r],m-2,m))%m;}
ll gcd(ll a, ll b) {return (b ? gcd(b, a % b) : a);}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll x,y,a,b;
	cin >> x >> y >> a >> b;
	ll t1=x,t2=0;
	int size3 = trunc(log10(y)) + 1;
	while(t1<y)
	{
		int size = trunc(log10(t1)) + 1;
		int size2 = trunc(log10(a)) + 1;
		if(size+size2>18 || size+size2>size3)
		{
			ll t3=(y-t1);
			t2+=(t3-1+b)/b;
			break;
		}
		if(t1+b<t1*a)
		{
			ll t3=(y-t1);
			t2+=(t3-1+b)/b;
			break;
		}
		else
		{
			t1*=a;
			t2++;
		}
	}
	cout << t2-1 << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ld long double
// g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o 

int main(){
 ll x,y,a,b;
 cin>>x>>y>>a>>b;
//  ll xd=x+b;
 ll exp=0;
 while(x*a<=x+b && (x*a>0)){
  x*=a;
  if(x>=y || x<=0){
   cout<<exp<<"\n";
   return 0;
  }
  exp++;
 }
//  cout<<exp<<"\n";
//  cout<<y-x<<"\n";
 exp+=((y-x-1)/b);
 cout<<exp<<"\n";
 return 0;
}
