#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, i, j, k, second, s;
  scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
  k = 0;
  if (d >= a) {
    s = a + b;
    k++;
    while (s <= d) {
      s = s * a + b;
      k++;
    }
  } else {
    s = d * a + b;
    k++;
    while (s < a) {
      s = s * a + b;
      k++;
    }
  }
  if (c - (k - 1) < 0)
    printf("0\n");
  else
    printf("%I64d\n", c - (k - 1));
}
