#include <bits/stdc++.h>
using namespace std;
long long int k, n, b, t, ctr, add, bac;
int main() {
  cin >> k >> b >> n >> t;
  bac = k + b;
  add = k;
  ctr = 0;
  while (bac <= t) {
    ctr++;
    bac = bac + add * (b - 1) + add * k;
    add = add * k;
  }
  if (ctr < n)
    cout << n - ctr << endl;
  else
    cout << "0";
  return 0;
}
