#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll f(ll h) {
  if (h == 1) {
    return 1;
  } else {
    return 2 * f(h / 2) + 1;
  }
}

ll mod = 1000000007;

ll powmod(ll a, ll b) {
  ll ret = 1;
  for (int i = 0; i < b; i++) {
    ret = (ret * a) % mod;
  }
  return ret;
}

ll comb(ll n, ll k) {
  map<string, ll> memo;
  if (n == k || k == 0) {
    return 1;
  } else {
    string key = to_string(n) + to_string(k);
    if (memo.count(key) != 0) {
      return memo[key];
    } else {
      ll v = comb(n - 1, k - 1) + comb(n - 1, k);
      memo[key] = v;
      return v;
    }
  }
}

int f(int n, int k) {
  int ret = 0;

  while (n < k) {
    n *= 2;
    ret++;
  }

  return ret;
}

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> v(N), box(K, -1);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  int i = 0;
  int prev = -1;
  for (auto a : v) {
    if (prev != a) {
      i = 0;
    }

    if (box[i] + 1 == a) {
      box[i] = a;
      i++;
    }

    prev = a;
  }

  ll ans = 0;
  for (auto a : box) {
    if (a != -1) {
      ans += (a + 1);
    }
  }
  cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
long long in(){
    long long x;
    cin>>x;
    return x;
}
int main(){
    long long x=in(),y=in(),a=in(),b=in(),ans=0;
    while(x<b/(a-1) && x<y/a)x*=a,ans++;
    ans+=(y-1-x)/b;
    cout<<ans<<endl;
    return 0;
}