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