#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
int main() {
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long tmp = b * n - t;
    tmp = (tmp / b) + 1;
    if (tmp < 0) tmp = 0;
    cout << tmp << endl;
    return 0;
  }
  double tmp = (double)(k - 1 + b) / (double)(k * t - t + b);
  tmp = log(tmp) / log(k);
  long long ans = (long long)tmp + n;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
