#include <bits/stdc++.h>
int main() {
  long long int k, b, n, t, i = 1, j = 1;
  scanf("%I64d %I64d %I64d %I64d", &k, &b, &n, &t);
  long long int result = 0;
  if (t == 1) {
    printf("%I64d", n);
    return 0;
  }
  i = i * k + b;
  for (i;; i = i * k + b) {
    if (n - j + 1 <= 0 || i > t) {
      result = n - j;
      break;
    }
    j++;
  }
  printf("%I64d", result + 1);
  return 0;
}
