#include <bits/stdc++.h>
using namespace std;
long long t, n, u, v, m, q, r, ql, qr, k, l, s, c, x, y, b;
const int N = 1e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57LL;
const bool JUDGE = false;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (JUDGE) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  cin >> k >> b >> n >> t;
  long long f = 1;
  int i = 0;
  for (;; ++i) {
    f = f * k + b;
    if (f > t) break;
  }
  cout << max(0LL, n - (long long)i) << '\n';
  return 0;
}
