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