#include <iostream>
#define pb push_back
using namespace std;
long long n,nr,i,a,b,y,xp,c;

int main()
{
    cin>>n>>y>>a>>b;
    xp=0;

        while(a <= (n + b) / n&&n*a<y)
        {
            xp++;
            n*=a;
        }
        /*else
        {
            c=(y-n)/b;
            xp+=c+1;
            if((y-n)%b==0)
                xp--;
            break;
        }*/


    xp+=(y-n-1)/b;
    cout<<xp;



    return 0;
}

#include <bits/stdc++.h>
using namespace std;  
using ll = long long;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
template <class T> using V = vector<T>;
#define ALL(v) (v).begin(),(v).end()
#define endl '\n'
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int dy2[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx2[] = {1, 1, 0, -1, -1, -1, 0, 1};
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
 
/*--------------------------------------------------------------------------------
--------------------------------------------------------------------------------*/

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

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}


int main() {
    __int128 x, y, a, b;
    string o, p, q, r;
    cin >> o >> p >> q >> r;
    x = parse(o), y = parse(p), a = parse(q), b = parse(r);
    ll cnt = 0;
    while(1){
        if(x*a < x+b){
            __int128 bfx = x;
            x *= a;
            if(bfx != x/a || x >= y){
                cout << cnt << endl;
                return 0;
            }
            cnt++;
        }
        if(x*a >= x+b){
            ll dif = y - x;
            ll add = dif/b;
            if(dif%b == 0) add--;
            cout << cnt+add << endl;
            return 0;
        }
    }

    return 0;
}

 