#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long x = power(a, b / 2);
  if (b % 2 == 0)
    return x * x;
  else
    return a * (x * x);
}
long long ceil_div(long long a, long long b) { return (a + b - 1) / b; }
int main() {
  ios_base::sync_with_stdio(false);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (t == 1)
    cout << n << endl;
  else if (k == 1) {
    long long z = 1 + (n * b);
    if (z <= t)
      cout << "0" << endl;
    else {
      int i = 1;
      while (t < z) {
        t = t + b;
        i++;
      }
      cout << i - 1 << endl;
    }
  } else {
    long double var = (((t * (k - 1) + b) * (1.0)) / (k - 1 + b));
    int i = 0;
    while (var >= power(k, i)) {
      i++;
    }
    if (n - i + 1 < 0) n = i - 1;
    cout << n - i + 1 << endl;
  }
}
