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