#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t, Tot, Tmp;
int main() {
  ios ::sync_with_stdio(false);
  cin >> k >> b >> n >> t;
  for (Tmp = 1; Tmp < t;) Tmp = Tmp * k + b, Tot++;
  if (Tmp > t) --Tot;
  if (Tot > n) Tot = n;
  cout << n - Tot << endl;
  return 0;
}
