#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t;
int main() {
  int i, j;
  cin >> k >> b >> n >> t;
  if (t == 1) {
    cout << n << endl;
    return 0;
  } else if (k == 1) {
    for (int m = 0; m <= n; m++) {
      if (m * b >= 1 + n * b - t) {
        cout << m << endl;
        break;
      }
    }
    return 0;
  }
  long long l = t * k - t + b, r = k - 1 + b;
  long long tmp = 1;
  int p;
  for (p = 0; p <= n; p++) {
    if (l < r * tmp) {
      break;
    }
    tmp = tmp * k;
  }
  cout << n - p + 1 << endl;
  return 0;
}
