#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 0;
const int MAXM = 0;
long long n, k, t, b, z;
int main() {
  z = 1;
  int ans = 0;
  cin >> k >> b >> n >> t;
  while (z <= t) {
    ans++;
    z = z * k + b;
  }
  if (z == t)
    ans = n - ans;
  else {
    ans--;
    ans = n - ans;
  }
  cout << max(0, ans) << endl;
  return 0;
}
