#include <bits/stdc++.h>
using namespace std;
int main() {
  double k, b, n, t;
  while (scanf("%lf%lf%lf%lf", &k, &b, &n, &t) != EOF) {
    double x = 1, cou = 0;
    while (x < t) {
      x = x * k + b;
      cou++;
    }
    if (n < cou) {
      printf("0\n");
      continue;
    }
    if (x == t)
      printf("%.0lf\n", n - cou);
    else
      printf("%.0lf\n", n - cou + 1);
  }
  return 0;
}
