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