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