#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long ans;
  if (k == 1) {
    long double p = 1 + n * b - t;
    ans = ceil(p / (b * 1.0));
    ans = max(ans, 0LL);
  } else {
    long double num = k * t - t + b;
    long double den = k - 1 + b;
    long double res = num / den;
    ans = (long long)(log2(res) / log2(k * 1.0));
    ans = max(n - ans, 0LL);
  }
  cout << ans;
}
