#include <iostream>

using namespace std;
using LL = long long;

LL x, y, EXP;
int a, b;

int main() {
  cin >> x >> y >> a >> b;
  while (x * a <= x + b) {
    if ((double)x * a >= 2e18 || x * a >= y) {
      break;
    }
    x *= a;
    EXP++;
  }

  if (!((y - x) % b)) {
    EXP += ((y - x) / b) - 1;
  } else {
    EXP += ((y - x) / (double)b);
  }
  cout << EXP << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;
void yesno(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
ll power(ll x, ll n, ll m){if(n==0)return 1;ll u=power(x,n/2,m);u=(u*u)%m;if(n%2)u=(u*x)%m;return u;}
/// * int overflow, array bounds
/// * special cases (n=1?)
/// * do something - write observations down
/// * change approaches


int main (){
fastio;

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

ll ans = 0;

while(x*a<y && x<b){
    x *= a;
    ans++;
}

ll diff = y-x-1;

cout<<ans+diff/b<<endl;






}
