#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  int b;
  int n;
  int t;
  int cont = 0;
  scanf("%d %d %d %d", &k, &b, &n, &t);
  if (t == 1)
    cont = n;
  else {
    cont = n;
    unsigned long long int aux = 1;
    while (t > aux) {
      aux = k * aux + b;
      cont--;
    }
    cont += !(t == aux);
  }
  cout << max(cont, 0) << endl;
  return 0;
}
