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