#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int sum, suf, pre, max;
} Node;
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
const int MAXN = 2e5 + 100;
const int UP = 31;
const int mod = 1e9 + 7;
const long long int highest = 1e18;
const double pi = acos(-1);
const double Phi = 1.618033988749894;
const int logn = 20;
const double root5 = 2.236067977;
const long long int inf64 = 1e16;
const int ini = -1e9;
long long int k, b, n, t, ans, cur;
int main() {
  cin >> k >> b >> n >> t;
  ans = n;
  cur = k + b;
  while (cur <= t) {
    cur = cur * k + b;
    --ans;
  }
  if (ans < 0) ans = 0;
  cout << ans << "\n";
  return 0;
}
