#include <bits/stdc++.h>
using namespace std;
double myabs(double x) { return x >= 0 ? x : -x; }
long long max(long long x, long long y) { return x > y ? x : y; }
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    if (t >= n * b + 1)
      cout << 0 << endl;
    else {
      if ((1 + n * b - t) % b == 0)
        cout << (1 + n * b - t) / b << endl;
      else
        cout << (1 + n * b - t) / b + 1 << endl;
    }
    return 0;
  }
  double tmp = (k - 1 + b + 0.0) / (t * k - t + b);
  double ret = log(tmp) + n * log(k + 0.0);
  ret /= log(k + 0.0);
  long long ans = (long long)ret;
  if (myabs(ans - ret) > 1e-8)
    cout << max(ans + 1, 0LL) << endl;
  else
    cout << max(ans, 0LL) << endl;
}
