#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, b, n, t;
  scanf("%I64d%I64d%I64d%I64d", &k, &b, &n, &t);
  if (k == 1) {
    long long int ans =
        (1 + n * b - t) / b + ((1 + n * b - t) % b == 0 ? 0 : 1);
    printf("%I64d\n", max(ans, 0ll));
  } else {
    double tmp = 1.0 * (k - 1 + b) / (k * t - 1.0 * t + b);
    double ans = log(tmp) / log(k);
    printf("%I64d\n", max((long long int)ceil(ans) + n, 0ll));
  }
}
