#include <bits/stdc++.h>
using namespace std;
int k, b, n, t;
int main() {
  cin >> k >> b >> n >> t;
  long long i(1LL);
  long long ans(0LL);
  for (; i <= t;) {
    ++ans;
    i *= k;
    i += b;
  }
  cout << max(0LL, n - ans + 1) << endl;
  ;
  return 0;
}
