#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long k, b, n, x;
  cin >> k >> b >> n >> x;
  long long sum = 1, cnt = 0;
  while (sum < x) {
    sum = k * sum + b;
    cnt++;
  }
  if (sum == x)
    cout << max(0LL, n - cnt);
  else
    cout << max(0LL, n - cnt + 1);
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
