#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long val = 1;
  long long cnt(0);
  while (val < t) {
    cnt++;
    val *= k;
    val += b;
  }
  cout << max((long long)0, n - cnt + (val != t));
}
