#include <bits/stdc++.h>
using namespace std;
int main() {
  int b, n, seconds, t;
  long double k, temp, temp2;
  while (cin >> k >> b >> n >> t) {
    if (k == 1) {
      seconds = ceil(n + 1.0 * (1 - t) / b);
    } else {
      temp = 1.0 * (k * t - t + b) / (k - 1 + b);
      seconds = 0;
      temp2 = 1;
      while (temp2 <= temp) {
        temp2 *= k;
        seconds++;
      }
      seconds--;
      seconds = n - seconds;
    }
    if (seconds < 0) seconds = 0;
    cout << seconds << endl;
  }
  return 0;
}
