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