#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000;
const long long MAX = 1000;
const long long inf = 1000 * 1000 * 1000;
const long long p1 = 104393321, p2 = 104393329;
int main(int argc, char **argv) {
  ios::sync_with_stdio(0);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) return cout << max(0ll, n - ((t - 1) / b)) << endl, 0;
  long long y = b + (k - 1) * t;
  long long x = b + k - 1;
  long long d = y / x;
  long long ans = 0;
  long long l = 1;
  while (l <= d) {
    l *= k;
    ans++;
    if (l == d) break;
  }
  if (l != d) ans--;
  cout << max(0ll, n - ans) << endl;
  return 0;
}
