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