#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
long double val;
bool f(int m) {
  m = n - m;
  long long ans = 1;
  for (int i = 0; i < m; i++) {
    ans *= k;
    if (ans > val) return false;
  }
  return true;
}
int main() {
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long ans = ceil((1 + n * b - t) / (b * 1.0));
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
  }
  long long s = 0, e = n, mid, ans;
  val = (t * k - t + b) * 1.0 / (k - 1 + b);
  while (s <= e) {
    mid = (s + e) / 2;
    if (f(mid)) {
      ans = mid;
      e = mid - 1;
    } else {
      s = mid + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
