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