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