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