#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, MOD = 1e9 + 7;
long long int k, b, n, t, res;
int main() {
  scanf("%lld%lld%lld%lld", &k, &b, &n, &t);
  res = n;
  long long int num = k + b;
  while (t >= num) {
    res--;
    num *= k;
    num += b;
  }
  cout << max(0LL, res);
  return 0;
}
