#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int LIMIT = 1e6 + 5;
LL dat[LIMIT];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  LL K, B, N, T;
  cin >> K >> B >> N >> T;
  LL Z = LIMIT + 5;
  dat[0] = 1;
  for (int i = 1; i <= N; i++) {
    dat[i] = dat[i - 1] * K + B;
    if (dat[i] > LIMIT) break;
    if (i == N) Z = dat[N];
  }
  if (T >= Z) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0;; i++) {
    if (dat[i] <= T && T < dat[i + 1]) {
      cout << N - i << endl;
      return 0;
    }
  }
}
