#include <bits/stdc++.h>
using namespace std;
double distance(int a, int b, int c, int d) {
  return sqrt((double)((a - c) * (a - c) + (b - d) * (b - d)));
}
int main() {
  ios_base::sync_with_stdio(false);
  int k, b, n, t;
  cin >> k >> b >> n >> t;
  long long cur = 1;
  for (long long i = 0;; ++i) {
    cur = k * cur + b;
    if (cur > t) {
      if (n - i >= 0)
        cout << n - i << endl;
      else
        cout << 0 << endl;
      return 0;
    }
  }
  return 0;
}
