#include <bits/stdc++.h>
using namespace std;
long long int n = 0, m, l = 0, k, a, b, c, sum = 0, i, r = 0, j, second, h,
              first = 0, sc, ans = 0, x, t, y;
double aa, pp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> k >> b >> n >> t;
  if (k == 1) {
    ans = (ceil((1 + n * b - t) * 1.0 / b));
    if (ans <= 0)
      cout << 0;
    else
      cout << ans;
    return 0;
  }
  aa = (t * (k - 1)) + t * b;
  aa = aa / (t * (k - 1) + b);
  pp = n * (log(k)) - log(t) + log(aa);
  pp = pp / log(k);
  if (pp - floor(pp) < 1e-12) {
    cout << setprecision(10) << floor(pp);
    return 0;
  }
  ans = ceil(pp);
  if (ans <= 0)
    cout << 0;
  else
    cout << ans;
}
