#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:268435456")
int main() {
  long long k, b, n, t, s = 1;
  cin >> k >> b >> n >> t;
  int i, j;
  int d = 0;
  while (s < t) {
    d++;
    s = s * k + b;
  }
  if (n - d < 0)
    cout << 0;
  else {
    if (s == t)
      cout << n - d;
    else
      cout << n - d + 1;
  }
  return 0;
}
