#include <bits/stdc++.h>
using namespace std;
bool not_possible(long long a, long long b) {
  if ((double)b * (double)log10((double)a) > 6.0) return true;
  return false;
}
int main() {
  long long k, b, t, n;
  scanf("%I64d %I64d %I64d %I64d", &k, &b, &t, &n);
  long long low = 0, high = t, mid, result = -1;
  while (low < high) {
    mid = low + (high - low) / 2;
    if (not_possible(k, t - mid)) {
      low = mid + 1;
      continue;
    }
    long long val = pow(k, t - mid);
    val = k == 1 ? val + b * (t - mid) : val + b * (val - 1) / (k - 1);
    if (val <= n) {
      high = mid;
      result = mid;
    } else
      low = mid + 1;
  }
  printf("%I64d\n", low);
  return 0;
}
