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