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