#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 6;
const long long M = 1e9 + 1;
void solve() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k > 1) {
    long double sum = (t * (k - 1) + b);
    sum /= (b + k - 1);
    long double l = 1;
    long long j = n;
    long long n1 = 0;
    while (n1 <= n) {
      l *= k;
      if (l > sum) break;
      n1++;
    }
    if (n - n1 <= 0)
      cout << 0;
    else
      cout << n - n1;
  } else {
    long long sum = k + (b * n) - t;
    long long ans = ceil((double)sum / (double)b);
    if (sum < 0)
      cout << 0;
    else
      cout << ans;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) solve();
}
