#include <bits/stdc++.h>
const int fin = 0;
int main() {
  if (fin) {
    freopen("t.in", "r", stdin);
    freopen("t.out", "w", stdout);
  }
  long long K, B, T, N, x, y, ans, i, step;
  scanf("%I64d%I64d%I64d%I64d", &K, &B, &N, &T);
  x = 1;
  for (i = 1;; ++i) {
    y = x * K + B;
    if (y >= T) break;
    x = y;
  }
  if (y == T)
    step = i;
  else
    step = i - 1;
  if (step >= N)
    ans = 0;
  else
    ans = N - step;
  printf("%I64d\n", ans);
  if (fin) {
    fclose(stdin);
    fclose(stdout);
  }
  return 0;
}
