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