#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:214721677")
using namespace std;
template <class T>
T sqr(T a) {
  return (a) * (a);
}
template <class T>
T abs(T a) {
  return (a < 0) ? -(a) : (a);
}
const double Pi = acos(-1.0);
const double eps = 1e-10;
const int INF = 1000 * 1000 * 1000;
const double phi = 0.5 + sqrt(1.25);
int main() {
  int k, b, n, t;
  scanf("%d%d%d%d\n", &k, &b, &n, &t);
  long long cur = 1, ans = n;
  bool ok = 1;
  while (cur <= t && ok) {
    if (cur * k + b <= t && ans - 1 >= 0) {
      cur = cur * k + b;
      --ans;
    } else
      ok = 0;
  }
  printf("%d\n", ans);
  return 0;
}
