#include <bits/stdc++.h>
using namespace std;
int k, b, n;
int t, adim;
long long mal;
long long int us(int a, int ab) {
  long long int ret = 1;
  for (int i = 1; i <= ab; i++) {
    cout << ret << endl;
    ret *= a;
  }
  return ret;
}
int main() {
  scanf("%d %d %d %d", &k, &b, &n, &t);
  adim = n;
  mal = 1;
  while (adim >= 0 && mal < t) {
    mal = mal * k + b;
    if (mal > t) break;
    adim--;
  }
  if (adim < 0) adim = 0;
  printf("%d\n", adim);
}
