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