#include <bits/stdc++.h>
using namespace std;
int DEBUG = 0;
int Min(int a, int b) { return (a < b ? a : b); }
int Max(int a, int b) { return (a > b ? a : b); }
int Abs(int a) { return (a >= 0 ? a : -a); }
void print1d(int *vec, int M, const char *str = NULL) {
  if (str != NULL) printf("%s ", str);
  for (int i = 0; i < M; i++) {
    if (i > 0) printf(" ");
    printf("%d", vec[i]);
  }
  printf("\n");
}
int ratio_ceil(int a, int 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;
  int k, b, n, t;
  cin >> k >> b >> n >> t;
  int z;
  int m;
  if (t == 1) {
    cout << n << endl;
  } else {
    if (k == 1) {
      z = 1 + n * b;
      m = ratio_ceil(z - t, b);
      cout << m << endl;
    } else {
      double x =
          log((1.0 + b + k - 1) / (1.0 + b + t * (k - 1))) / log(1.0 * k) + n;
      if (x < 0) {
        m = 0;
      } else {
        if ((x - int(x)) > 1.0e-10)
          m = int(x) + 1;
        else
          m = int(x);
      }
      cout << m << endl;
    }
  }
  return 0;
}
