#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, l, n, m, t, T, f, cur, p, ans, cnt, par, ele, r1, r2,
      tmp, b;
  scanf("%I64d", &k);
  scanf("%I64d", &b);
  scanf("%I64d", &n);
  scanf("%I64d", &t);
  ans = n;
  cur = k + b;
  while (cur <= t) {
    cur = cur * k + b;
    ans--;
  }
  if (ans < 0) ans = 0;
  printf("%I64d\n", ans);
  return 0;
}
