#include <bits/stdc++.h>
using namespace std;
long long modulo = (long long)1e9 + 7;
const long long N = (long long)1e5 + 10;
long long fpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % modulo;
    a = (a * a) % modulo;
    b = b >> 1;
  }
  return ans;
}
void solve() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    long long a = (1 + n * b - t);
    a = max(a, 0ll);
    if (a % b != 0) {
      a /= b;
      a += 1;
    } else {
      a /= b;
    }
    a = max(a, 0ll);
    cout << a << '\n';
    return;
  }
  long double a = t * (k - 1) + b;
  a = a / (k - 1 + b);
  long long val = 1;
  long long ans = n;
  for (long long i = n; i >= 0; i--) {
    if (val <= a) {
      ans = i;
    } else {
      break;
    }
    val *= k;
  }
  long double qq = t * (k - 1) + b;
  qq /= (k - 1 + b);
  val = k;
  for (long long i = 1; i < n + 1; i++) {
    if (val > qq) {
      cout << ans << '\n';
      return;
    }
    val = val * k;
  }
  cout << 0 << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) solve();
  return 0;
}
