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