#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
bool check(long long x) {
  if (n == x) return true;
  long long now = 1, num = 0, v = 1;
  while (now < t) {
    num++;
    now *= k;
  }
  if (num <= n - x) return false;
  for (long long i = 1; i <= n - x; i++) {
    v *= k;
  }
  return v + b * (v - 1) / (k - 1) <= t;
}
int main() {
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long v = 1 + b * n;
    long long l = (v - t + b - 1) / b;
    l = max((long long)0, l);
    cout << l << endl;
    return 0;
  }
  long long l = 0, r = n;
  while (r >= l) {
    long long mid = (l + r) / 2;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << r + 1 << endl;
}
