#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  int cnt = 0;
  long long cur = 1;
  while (k * cur + b <= t) {
    cur = cur * k + b;
    cnt++;
  }
  cout << max(n - cnt, 0ll) << endl;
  return 0;
}
