#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long z = 1 + n * b;
    for (int i = 0; i <= n; ++i) {
      if ((t + i * b) >= z) {
        cout << i << "\n";
        return 0;
      }
    }
  }
  for (int i = 0; i <= n; ++i) {
    if ((n - i) * log(k) <=
        log((1.0 * (k - 1) * t + b) / (1.0 * (k + b - 1)))) {
      cout << i << "\n";
      return 0;
    }
  }
  return 0;
}
