#include <bits/stdc++.h>
using namespace std;
void solve() {
  int k, b, n, t;
  cin >> k >> b >> n >> t;
  long long num = 1;
  int passed = 0;
  while (num < t) {
    num = k * num + b;
    passed++;
  }
  int ans = n - passed + 1;
  if (num == t) ans--;
  ans = max(0, ans);
  cout << ans << endl;
}
int main() {
  cout.sync_with_stdio(false);
  solve();
  return 0;
}
