#include <bits/stdc++.h>
using namespace std;
int64_t DEBUG = 0;
int64_t Min(int64_t a, int64_t b) { return (a < b ? a : b); }
int64_t Max(int64_t a, int64_t b) { return (a > b ? a : b); }
int64_t Abs(int64_t a) { return (a >= 0 ? a : -a); }
void print1d(int64_t *vec, int64_t M, const char *str = NULL) {
  if (str != NULL) printf("%s ", str);
  for (int64_t i = 0; i < M; i++) {
    if (i > 0) printf(" ");
    printf("%d", vec[i]);
  }
  printf("\n");
}
int64_t ratio_ceil(int64_t a, int64_t b) {
  if (a % b == 0)
    return a / b;
  else
    return (1 + a / b);
}
int main(int argc, char **argv) {
  DEBUG = (argc >= 2) ? atoi(argv[1]) : 0;
  int64_t k, b, n, t;
  cin >> k >> b >> n >> t;
  int64_t z;
  int64_t m;
  if (t == 1) {
    cout << n << endl;
  } else {
    if (k == 1) {
      for (m = 0; m <= n; m++) {
        if ((t + m * b) >= (1 + n * b)) {
          cout << m << endl;
          exit(0);
        }
      }
    } else {
      int64_t A = t * (k - 1) + b;
      int64_t B = (k - 1 + b);
      int64_t kpow = 1;
      int64_t biggest_d = 0;
      for (int64_t d = 0; d <= n; d++) {
        if (A >= (B * kpow)) {
          biggest_d = d;
        } else {
          break;
        }
        kpow *= k;
      }
      cout << (n - biggest_d) << endl;
    }
  }
  return 0;
}
