#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
int main() {
  ios::sync_with_stdio(false);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long res = 0;
  if (k == 1) {
    for (long long i = 0; i < N; i++) {
      if (1 + n * b <= t + i * b) {
        res = i;
        break;
      }
    }
    cout << max(0ll, res) << "\n";
    return 0;
  }
  long long start = ((k - 1) + b);
  for (long long i = 1; i < N; i++) {
    start *= k;
    if (start > t * (k - 1) + b) {
      res = n - (i - 1);
      break;
    }
  }
  cout << max(0ll, res) << "\n";
  return 0;
}
