#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t, x, z;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> k >> b >> n >> t;
  x = 1;
  while (k * x + b <= t) x = k * x + b, n--;
  if (n > 0)
    cout << n;
  else
    cout << 0;
  return 0;
}
