#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, b, n, t, a = 1, cnt = 0;
  scanf("%lld%lld%lld%lld", &k, &b, &n, &t);
  for (int i = 1; i <= n; i++) {
    a = a * k + b;
    if (cnt == 0 && a > t) {
      cnt = i;
      break;
    }
  }
  cnt != 0 ? printf("%lld", n - cnt + 1) : printf("0");
}
