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