#include <bits/stdc++.h>
using namespace std;
int k, b, n, t;
bool check(int T) {
  long long sum = (T == n ? 1 : b) - t, kk = k;
  for (int i = T + 1; sum <= 0 && i <= n; ++i) {
    if (i == n)
      sum += kk;
    else
      sum += b * kk;
    kk *= k;
  }
  return sum <= 0;
}
int main() {
  scanf("%d%d%d%d", &k, &b, &n, &t);
  int l = 0, r = n - 1, m, res = n;
  while (l <= r) {
    m = (l + r) / 2;
    if (check(m)) {
      r = m - 1;
      res = m;
    } else
      l = m + 1;
  }
  printf("%d\n", res);
  return 0;
}
