#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T a) {
  return a < 0 ? -a : a;
}
template <typename T>
T sqr(T a) {
  return a * a;
}
const int INF = (int)1e9;
const long double EPS = 1e-9;
const long double PI = 3.1415926535897932384626433832795;
long long k, b, n, t;
int main() {
  cin >> k >> b >> n >> t;
  long long sec = 0;
  long long cur = 1;
  while (cur <= t) {
    sec++;
    cur = cur * k + b;
  }
  sec--;
  sec = min(sec, n);
  cout << n - sec << endl;
  return 0;
}
