#include <bits/stdc++.h>
using namespace std;
const long long int N = (1e6);
const long long int mod = (1e9 + 7);
int main() {
  long long int k, b, n, t;
  cin >> k >> b >> n >> t;
  long long int x = 1;
  int p = -1;
  for (long long int i = 1; i <= n; i++) {
    x = x * k + b;
    if (x == t) p = i;
    if (x > t) {
      p = i - 1;
      break;
    }
  }
  if (p != -1)
    cout << n - p;
  else
    cout << 0;
}
