#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
int main() {
  cin >> k >> b >> n >> t;
  int temp = 0;
  long long acc = 1;
  while (acc <= t) {
    acc *= k;
    acc += b;
    temp++;
  }
  int ans = n - temp + 1;
  if (ans < 0)
    cout << 0 << endl;
  else
    cout << ans << endl;
}
