#include <bits/stdc++.h>
using namespace std;
long long second(long long k, long long x, long long b) { return (k * x + b); }
void solve() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long x, c = 0;
  x = 1;
  while (x < t) {
    c++;
    x = second(k, x, b);
  }
  if (x > t) c--;
  cout << max(0LL, n - c);
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long t = 1;
  while (t--) solve();
  return 0;
}
