#include <bits/stdc++.h>
using namespace std;
double solve(double k, double b, double t) {
  double ans = b / (k - 1);
  return t + ans;
}
int main() {
  double k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    double ans = n * b + 1;
    double ans1 = ans - t;
    ans1 /= b;
    ans1 = ceil(ans1 - 1e-9);
    if (ans1 <= 0)
      cout << 0 << endl;
    else
      cout << (int)ans1 << endl;
  } else {
    double k4 = solve(k, b, 1);
    double k1 = solve(k, b, t);
    double k2 = k4 / k1;
    double k3 = log(k2) / log(k);
    k3 += n;
    int gg = ceil(k3 - 1e-9);
    if (gg < 0)
      cout << 0 << endl;
    else
      cout << gg << endl;
  }
  return 0;
}
