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