#include <bits/stdc++.h>
using namespace std;
void solve();
signed main() {
  cout.precision(10);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  long long tt = t;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long lol = 1 + n * b;
    for (long long i = 0;; i++) {
      if (t >= lol) {
        cout << i;
        return;
      }
      t += b;
    }
  }
  long long kk = 1;
  long long mx = 0;
  for (long long i = 0; i <= n; i++) {
    if ((t - kk) * (k - 1) >= b * (kk - 1))
      mx = i;
    else
      break;
    kk *= k;
  }
  cout << n - mx;
}
