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