#include <bits/stdc++.h>
using namespace std;
int main() {
  double k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1)
    cout << max(0, (int)ceil((1 + b * n - t) / b));
  else {
    bool OK = false;
    double y = (b + t * (k - 1)) / (b + k - 1);
    for (int x = (int)n; x >= 0; x--) {
      double p = pow(k, n - x);
      if (p > y + 0.0000001) {
        cout << x + 1;
        OK = true;
        break;
      }
    }
    if (!OK) cout << 0;
  }
}
