#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, b, n, t, a, p, ans;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    cout << max(0, int((1 + (b * n) - t) / b + ((1 + (b * n) - t) % b != 0)));
    return 0;
  }
  ans = n;
  p = 1;
  a = ((t * (k - 1)) + b) / (k - 1 + b);
  while (p <= a) {
    ans--;
    p = p * k;
  }
  if (ans < 0) ans = -1;
  cout << ans + 1;
  return 0;
}
