#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long p = 1;
  long long q = p;
  int r = 0;
  while (p < t) {
    q = p;
    p = p * k + b;
    r++;
  }
  if (r > n) {
    cout << "0" << endl;
    return 0;
  }
  if (p == t) {
    cout << n - r << endl;
  } else
    cout << n - r + 1 << endl;
}
