#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int M = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  double k, b, n, t, i;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    double f = (1 + n * b - t) / (b);
    for (i = 0; i <= n; i++) {
      if (i >= f) {
        break;
      }
    }
    cout << (long long)i << endl;
    return 0;
  }
  double f = b / (k - 1);
  double r = (t + f) / (1 + f);
  double foo = 1;
  for (i = 1; i <= n; i++) {
    foo *= k;
    if (foo > r) {
      long long ans = (long long)n - (long long)(i - 1);
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}
