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