#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, k, t;
  cin >> k >> b >> n >> t;
  double CC = (double)((double)k * t - t + b) / (k - 1 + b);
  if (k == 1) {
    int ans = max(n - t / b, 0);
    if (t % b == 0 && n - t / b >= 0) {
      ans++;
    }
    cout << ans << endl;
    return 0;
  }
  int ans = 1000000;
  for (int i = n; i >= 0; i--) {
    double cur = pow(k, n - i);
    if (cur <= CC || (fabs(cur - CC) <= (1e-9))) {
      ans = i;
    } else {
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}
