#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long ans = n;
  long long c1 = k, c2 = b;
  while (ans > 0 && t >= c1 + c2) {
    --ans;
    c1 *= k;
    c2 = c2 * k + b;
  }
  cout << ans << endl;
}
