#include <bits/stdc++.h>
using namespace std;
long long kp[1000010], s[1000010];
int main() {
  ios_base::sync_with_stdio(0);
  long long k, b, n, t;
  while (cin >> k >> b >> n >> t) {
    kp[0] = 1;
    if (k == 1)
      for (int i = (0); i < ((1000010)); ++i) kp[i] = 1;
    else
      for (int i = 1; kp[i - 1] <= t; ++i) kp[i] = k * kp[i - 1];
    s[0] = b * kp[0];
    for (int i = 1; s[i - 1] <= t; ++i) s[i] = b * kp[i] + s[i - 1];
    for (int i = 0;; ++i) {
      if (kp[i + 1] + s[i] > t) {
        cout << max(0LL, n - i) << endl;
        break;
      }
    }
  }
  return 0;
}
