#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1164777216")
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double pi = acos(-1.0), eps = 1e-15;
const int INF = 1000 * 1000 * 1000 + 5, MAXN = 100005, MOD = 1000007;
const long long INFL = 1000000000000000005;
void prepare(string s) {
  if ((int)s.size() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
long long k, b, n, t;
long long Pow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
void solve() {
  cin >> k >> b >> n >> t;
  if (t >= 1 && t < k + b) {
    cout << max(0LL, n);
    return;
  }
  if (t >= k + b && t < k * k + k * b + b) {
    cout << max(0LL, n - 1);
    return;
  }
  if (t >= k * k + k * b + b && t < k * k * k + k * k * b + k * b + b) {
    cout << max(0LL, n - 2);
    return;
  }
  if (t >= k * k * k + k * k * b + k * b + b &&
      t < k * k * k * k + k * k * k * b + k * k * b + k * b + b) {
    cout << max(0LL, n - 3);
    return;
  }
  if (t >= k * k * k * k + k * k * k * b + k * k * b + k * b + b &&
      t < k * k * k * k * k + k * k * k * k * b + k * k * k * b + k * k * b +
              k * b + b) {
    cout << max(0LL, n - 4);
    return;
  }
  if (t > k * k * k * k * k + k * k * k * k * b + k * k * k * b + k * k * b +
              k * b + b &&
      t <= k * k * k * k * k * k + k * k * k * k * k * b + k * k * k * k * b +
               k * k * k * b + k * k * b + k * b + b) {
    cout << max(0LL, n - 5);
    return;
  }
  long long cur = 1, sr = k + b;
  for (int i = 0; i <= n; i++) {
    if (t >= cur && t < sr) {
      cout << n - i;
      return;
    }
    cur = sr;
    sr -= Pow(k, i + 1);
    sr += Pow(k, i + 1) * b;
    sr += Pow(k, i + 2);
  }
  cout << 0;
}
int main() {
  prepare("");
  srand(time(NULL));
  solve();
  return 0;
}
