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