#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t, cnt = 1;
int main() {
  scanf("%lld%lld%lld%lld", &k, &b, &n, &t);
  while (cnt <= t) {
    cnt = cnt * k + b;
    n--;
  }
  printf("%lld\n", max(n + 1, 0LL));
  return 0;
}
