#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
const int MOD = 1000000007;
const int INF = 1e8;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-7;
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    cout << max(0LL, ((1 + n * b - t + b - 1) / (b))) << '\n';
  } else {
    long long num = t * (k - 1) + b;
    long long denom = k - 1 + b;
    long long knt = 1, res = 0;
    for (long long i = 0; i <= n; i++) {
      if (knt * denom > num) {
        res = n - (i - 1);
        break;
      }
      knt = knt * k;
    }
    cout << res << '\n';
  }
  return 0;
}
