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