#include <bits/stdc++.h>
using namespace std;
int main() {
  long double k, b, n, t;
  cin >> k >> b >> n >> t;
  long double h = 0;
  if (k != 1) {
    h = log(b + k - 1) / log(k);
    h -= log(b + t * k - t) / log(k);
    h += n;
    h = ceil(h);
    long long q = h;
    if (h < 0) {
      cout << 0 << endl;
      return 0;
    }
    cout << q << endl;
  } else {
    h = (1 + n * b - t) / b;
    h = ceil(h);
    long long q = h;
    if (h < 0) {
      cout << 0 << endl;
      return 0;
    }
    cout << q << endl;
  }
  return 0;
}
