#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
bool compa(pair<long long, long long> p1, pair<long long, long long> p2) {
  return p2.second < p1.second;
}
void fun() {
  long long i, j, flag = 0, d1, d2, maxz = 0, q, b, x, y1, l, r,
                  ans = LLONG_MAX, min, mid, y, m, minz;
  string o;
  long long n, k, f, t;
  cin >> k >> b >> n >> t;
  x = 1;
  i = 0;
  while (x <= t) {
    x = k * x + b;
    i++;
  }
  if (i > n) {
    cout << "0" << endl;
    return;
  }
  cout << n - i + 1 << endl;
}
int main() {
  long long t, n, k, i;
  t = 1;
  for (long long i = 1; i <= t; i++) fun();
}
