#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long k, b, n, t, tmp = 1, time = 0;
  scanf("%I64d%I64d%I64d%I64d", &k, &b, &n, &t);
  while (tmp < t) {
    tmp = tmp * k + b;
    time++;
  }
  if (tmp > t) time--;
  if (time > n) time = n;
  printf("%d", n - time);
  return 0;
}
