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