#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, B, N, T;
  scanf("%d%d%d%d", &K, &B, &N, &T);
  int Count = 0;
  long long S = 1;
  while (S <= T) {
    Count++;
    S = S * K + B;
  }
  printf("%d\n", max(N - Count + 1, 0));
  return 0;
}
