#include <bits/stdc++.h>
using namespace std;
template <class T>
string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int nint() {
  int x;
  scanf("%d", &x);
  return x;
}
const long long mod = 1000000000 + 7;
int m;
int n;
long long ans;
int main() {
  do {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  } while (0);
  long long k, b, n, t;
  cin >> k >> b >> t >> n;
  long long c = 1;
  while (c <= n) {
    t--;
    c = c * k + b;
  }
  t++;
  cout << max(0ll, t);
}
