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