#include <bits/stdc++.h>
using namespace std;
bool check(long long k, long long b, long long n, long long t, long long r) {
  long long tb = b;
  long long tr = t;
  long long kpow = 0, kp = 1;
  while (tr >= 0 && kpow < n - r) {
    tr -= tb;
    tb *= k;
    kp *= k;
    kpow++;
  }
  tr -= kp;
  if (tr >= 0) return true;
  return false;
}
int main() {
  int k, b, n, t;
  cin >> k >> b >> n >> t;
  int l = 0, r = n;
  while (l != r) {
    if (l == r - 1) {
      if (check(k, b, n, t, l))
        r = l;
      else
        l = r;
      break;
    }
    int m = (l + r) / 2;
    if (check(k, b, n, t, m))
      r = m;
    else
      l = m;
  }
  cout << l << "\n";
  return 0;
}
