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