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