#include <bits/stdc++.h>
using namespace std;
long long s(long long a, long long b) {
  if (a % b) return a / b + 1;
  return a / b;
}
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    if (s(1 + (n * b) - t, b) <= 0)
      cout << 0 << "\n";
    else
      cout << s(1 + (n * b) - t, b) << "\n";
  } else {
    long long a = (t * (k - 1) + b);
    long long d = (k - 1 + b);
    long long c = a / d;
    long long ans = 0;
    long long kk = 1;
    while (1) {
      if (kk > c) {
        ans--;
        break;
      }
      kk *= k;
      ans++;
    }
    if (ans > n) ans = n;
    ans = n - ans;
    cout << ans << "\n";
  }
  return 0;
}
