#include <bits/stdc++.h>
using namespace std;
double eps = 1e-9;
const int INF = 1e9 + 7;
const int MAXN = int(2e5 + 7);
int n, k, b, ans;
long long cur = 1, t;
int main() {
  cin >> k >> b >> n >> t;
  while (cur <= t) {
    cur = cur * k + b;
    n--;
  }
  cout << max(0, ++n);
  return 0;
}
