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