#include <bits/stdc++.h>
using namespace std;
const long long int infinity = 1000000000000000000LL;
int main() {
  long long lola = 1;
  long long b, t, k, n, ans;
  cin >> k >> b >> n >> t;
  if (k == 1) ans = (long long)(ceil(1.0 * (1 + n * b - t) / b));
  lola = 1;
  if (k != 1)
    for (int diff = 0; lola <= infinity; diff++) {
      if (diff == 0)
        lola = 1;
      else
        lola *= k;
      if (b + t * k - t >= lola * (b + k - 1)) {
        ans = n - diff;
        continue;
      } else
        break;
    }
  cout << max(ans, 0LL) << endl;
  cin >> ans;
  return 0;
}
