#include <bits/stdc++.h>
using namespace std;
int main() {
  long long z, x = 1, k, b, n, t, S = 1;
  cin >> k >> b >> n >> t;
  while (x <= t) {
    x = x * k + b;
    n--;
  }
  if (n < 0)
    cout << "0";
  else
    cout << n + 1;
}
