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