#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int k, b, n, t;
  cin >> k >> b >> n >> t;
  long long bac = 1;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (bac > t) {
      break;
    }
    bac = k * bac + b;
    ans++;
  }
  cout << n - ans + 1 << endl;
}
