#include <bits/stdc++.h>
using namespace std;
int n;
int solve(int m, int k, int b, int t) {
  long long sum = 0;
  for (int i = 0; i < n - m; i++) {
    sum = sum * k + b;
    if (sum > t) return 0;
  }
  long long s = 1;
  for (int i = 1; i <= n - m; i++) {
    s *= k;
    if (s > t) return 0;
  }
  if (s + sum > t) return 0;
  return 1;
}
int main() {
  int k, b, t;
  scanf("%d%d%d%d", &k, &b, &n, &t);
  int left = 0, right = n, mid, ans;
  while (left <= right) {
    mid = (left + right) / 2;
    if (solve(mid, k, b, t)) {
      ans = mid;
      right = mid - 1;
    } else
      left = mid + 1;
  }
  printf("%d\n", ans);
}
