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