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