#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  int x = 1;
  while (k * x + b <= t) x *= k, x += b, n--;
  cout << max((long long)0, n);
}
