#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
void solve() {
  cin >> k >> b >> n >> t;
  long long x = 1;
  int time = 0;
  while (x < t) {
    ++time;
    x = k * x + b;
  }
  cout << (n - time < 0 ? 0 : n - time + (x == t ? 0 : 1)) << endl;
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  ;
  int tt;
  tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
