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