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