#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long k, b, n, t, m, zm = 1;
  cin >> k >> b >> n >> t;
  for (m = 0; m < n && zm < t; ++m) zm = k * zm + b;
  if (zm > t) m--;
  cout << n - m << endl;
  return 0;
}
