#include <bits/stdc++.h>
int main() {
  int k, b, n, t, res;
  long long tmp;
  scanf("%d%d%d%d", &k, &b, &n, &t);
  res = n;
  tmp = 1;
  while (res > 0 && tmp < t) {
    res--;
    tmp = tmp * k + b;
  }
  if (tmp > t) res++;
  printf("%d\n", res);
  return 0;
}
