#include <bits/stdc++.h>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T>
void smin(T& a, T val) {
  if (a > val) a = val;
}
template <class T>
void smax(T& a, T val) {
  if (a < val) a = val;
}
const long long N = 5 * (long long)1e5 + 10;
long long n, k, b, t;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long ans = (b * n - t + b) / b;
    cout << max(ans, 0LL);
    exit(0);
  }
  long long diff = 0;
  long long poww = k;
  long long rhs = t * k - t + b;
  for (diff = 1; diff <= n; ++diff) {
    long long lhs = (k - 1 + b) * poww;
    if (lhs > rhs) {
      cout << n - (diff - 1);
      exit(0);
    }
    poww *= k;
  }
  cout << 0;
  return 0;
}
