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