#include <bits/stdc++.h>
using namespace std;
int k, b, t, n;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long calc(int i) {
  long long res = binpow(k, i);
  i--;
  for (; i >= 0; i--) {
    res += binpow(k, i) * b;
  }
  return res;
}
int main() {
  int ans = 0;
  cin >> k >> b >> n >> t;
  if (t == 1)
    cout << n;
  else {
    long long res = 1;
    for (long long i = 0; i < n; i++) {
      long long next = res * k + b;
      if (t >= res && t <= next - 1) {
        cout << n - i;
        return 0;
      } else
        res = next;
    }
    cout << 0;
  }
  return 0;
}
