#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, b, n, t, ans = 1;
  unsigned long long z, z1;
  long long i, j;
  scanf("%I64d%I64d%I64d%I64d", &k, &b, &n, &t);
  z1 = 1;
  while (z1 <= t) {
    z1 = k * z1 + b;
    n--;
  }
  if (n >= 0)
    cout << n + 1;
  else
    cout << "0\n";
  return 0;
}
