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