#include <bits/stdc++.h>
using namespace std;
int A[100002];
int main() {
  long long N_1 = 1;
  int k, b, n, t;
  scanf("%d %d %d %d", &k, &b, &n, &t);
  long long N_2 = t;
  long long count = 0;
  while (N_1 <= N_2) {
    N_1 = N_1 * k + b;
    count++;
  }
  count--;
  if (count > n)
    count = 0;
  else
    count = n - count;
  printf("%I64d\n", count);
  return 0;
}
