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