#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long now = 1, res = n;
  if (k == 1) {
    long long nn = 1 + n * b - t;
    if (nn <= 0) {
      puts("0");
      return 0;
    }
    long long dd = b;
    long long rr;
    if (nn % dd)
      rr = nn / dd + 1;
    else
      rr = (nn + dd - 1) / dd;
    cout << max(rr, 0LL) << endl;
    return 0;
  }
  long long nn = t * (k - 1) + b;
  long dd = (k - 1) + b;
  long long to;
  if (nn % dd)
    to = nn / dd;
  else
    to = (nn + dd - 1) / dd;
  while (res >= 0) {
    now *= k;
    if (now <= to)
      ;
    else
      break;
    res--;
  }
  res = max(res, 0LL);
  cout << res << endl;
  return 0;
}
