#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  double k, b, n, t, z;
  while (cin >> k >> b >> n >> t) {
    int res, temp;
    if (k == 1) {
      z = (n * b + 1 - t) / b;
      if (z < 0) {
        res = 0;
        cout << res << endl;
        continue;
      }
      temp = (int)z;
      if (n * b + 1 - t <= temp * b)
        res = temp;
      else
        res = temp + 1;
    } else {
      z = ((n + 1) * log(k) - log((k - 1) * t + 1)) / log(k);
      if (z < 0) {
        res = 0;
        cout << res << endl;
        continue;
      }
      temp = int(z);
      if ((n + 1) * log(k) - log((k - 1) * t + 1) <= temp * log(k))
        res = temp;
      else
        res = temp + 1;
    }
    res = max(res, 0);
    cout << res << endl;
  }
  return 0;
}
