#include <bits/stdc++.h>
using namespace std;
long long now, k, b, n, m;
int main() {
  cin >> k >> b >> n >> m;
  now = 1;
  for (long long i = 1; i <= n; i++)
    if (now <= m && k * now + b > m) {
      cout << n - i + 1 << endl;
      return 0;
    } else
      now = k * now + b;
  cout << 0 << endl;
  return 0;
}
