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