#include <bits/stdc++.h>
using namespace std;
void prepare() {}
void solve() {
  unsigned long long k, n, b, t;
  cin >> k >> b >> n >> t;
  unsigned long long ans = n;
  unsigned long long p = 1, q = 0;
  while (t >= p + b * q) {
    --ans;
    q += p;
    p *= k;
  }
  cout << ((ans < n) ? ans + 1 : 0) << endl;
}
int main() {
  prepare();
  solve();
  return 0;
}
