#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long k, b, n, t;
long long LT(long long n, long long x) {
  long long res = 1;
  for (long long i = 1; i <= x; i++) res *= n;
  return res;
}
long long check(long long i) {
  if (t * (k - 1) + b - LT(k, n - i) * (k - 1 + b) >= 0) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long res = (1 + n * b - t) / b;
    if ((1 + n * b - t) % b) res++;
    cout << max(res, 0LL);
    return 0;
  } else {
    for (long long i = n; i >= 0; i--) {
      if (check(i) == 0) {
        cout << i + 1;
        return 0;
      }
    }
  }
  cout << 0;
  return 0;
}
