#include <bits/stdc++.h>
using namespace std;
long long first(long long k, long long b, long long n) {
  long long res = 1;
  for (int i = 1; i <= n; i++) {
    res = (res * k) + b;
  }
  return res;
}
int find(long long z, long long k, long long b, long long t) {
  int time = 0;
  long long res = t;
  while (res < z) {
    res = (res * k) + b;
    time++;
  }
  return time;
}
int main() {
  long long n, b, k, t;
  cin >> k >> b >> n >> t;
  long long temp1 = t * (k - 1) + b;
  long long temp2 = (k - 1) + b;
  long long time = 0, sub = 1;
  if (k == 1) {
    long long z = first(k, b, n);
    time = find(z, k, b, t);
    cout << time << endl;
    return 0;
  }
  sub = 1;
  while ((sub * temp2) <= temp1) {
    sub = sub * k;
    time++;
  }
  time--;
  time = n - time;
  if (time < 0) time = 0;
  cout << time << endl;
  return 0;
}
