#include <bits/stdc++.h>
using namespace std;
long long n, k, b, x, kol = 0, t, otv;
bool prov(int v) {
  int ch = 1, kolvo = 0;
  for (int j = 1; j <= n - v; j++) {
    ch *= k;
    if (ch > t) break;
  }
  kolvo = ch;
  if (kolvo > t) return false;
  for (int i = n - v - 1; i >= 0; i--) {
    ch = 1;
    for (int j = 1; j <= i; j++) {
      ch *= k;
      if (kolvo + ch * b > t) break;
    }
    kolvo += ch * b;
    if (kolvo > t) return false;
  }
  if (kolvo <= t)
    return true;
  else
    return false;
}
int bin_search() {
  int l = 0, r = n, m;
  while (l < r) {
    m = (r + l) / 2;
    if (prov(m) == true)
      r = m;
    else
      l = m + 1;
  }
  return r;
}
int main() {
  cin >> k >> b >> n >> t;
  if (k == 1) {
    kol = 1;
    int q = 0;
    while (kol < t) {
      if (kol + b >= t) break;
      kol += b;
      q++;
    }
    cout << max(n - q, 0ll) << endl;
    return 0;
  }
  otv = bin_search();
  cout << otv;
  return 0;
}
