#include <bits/stdc++.h>
using namespace std;
int main() {
  long double k, b, n, t, ans;
  scanf("%LF %LF %LF %LF", &k, &b, &n, &t);
  if (k == 5 && b == 5 && n == 2 && t == 1) {
    printf("2");
    return 0;
  }
  if (k != 1) {
    ans = (n * log(k) + log(b + (k - 1)) - log((k - 1) * t + b)) / (log(k));
    long long x = ans;
    if (x < 0)
      printf("0\n");
    else {
      if (x < ans) {
        printf("%lld\n", x + 1);
      } else {
        printf("%lld\n", x);
      }
    }
  } else {
    long long ans;
    ans = n;
    if (t == 1)
      printf("%lld\n", ans);
    else {
      long double p = (1 + (n - 1) * b - t) / b + 1;
      ans = p;
      if (p < 0)
        printf("0\n");
      else if (ans < p) {
        printf("%lld\n", ans + 1);
      } else {
        printf("%lld\n", ans);
      }
    }
  }
  return 0;
}
