#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
int main() {
  long long r = 0, K;
  cin >> k >> b >> n >> t;
  if (t == 1) {
    cout << n;
    return 0;
  }
  if (k == 1) {
    r = (1 + n * b - t + b - 1) / b;
    cout << (((r) > (0)) ? (r) : (0));
    return 0;
  }
  r = n - 1;
  K = k;
  while (1) {
    if (K + b * (1.0 - K) / (1.0 - k) > t) break;
    K *= k;
    --r;
    if (r < 0) break;
  }
  cout << r + 1;
  return 0;
}
