#include <bits/stdc++.h>
using namespace std;
long long int a;
long long int b;
long long int c;
long long int d;
int main() {
  scanf("%d %d %d %d", &a, &b, &c, &d);
  long long int temp = 1;
  int coun = -1;
  do {
    temp *= a;
    temp += b;
    coun++;
  } while (d >= temp);
  cout << max(c - coun, (long long int)(0));
  return 0;
}
