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