#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long k, b, n, t;
  cin >> k;
  cin >> b;
  cin >> n;
  cin >> t;
  long long s = 1;
  long long steps = 0;
  while (s <= t) {
    s = s * k + b;
    ++steps;
  }
  --steps;
  n -= steps;
  n = max(0ll, n);
  cout << n << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(numeric_limits<long double>::digits10 + 1);
  int n = 1;
  for (long long i = 0; i < n; ++i) {
    solve();
  }
  return 0;
}
