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