#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int k, b, n, t, i, x = 1;
  cin >> k >> b >> n >> t;
  if (t == 1) {
    cout << n;
    return 0;
  }
  for (i = 1; i <= n; ++i) {
    x = (k * x) + b;
    if (t == x) {
      cout << n - i;
      return 0;
    }
    if (t < x) {
      cout << n - i + 1;
      return 0;
    }
  }
  cout << "0";
  return 0;
}
