#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9;
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
int main() {
  long long k, b, n, t, z;
  cin >> k >> b >> n >> t;
  z = 1;
  while (t >= z * k + b) {
    z = z * k + b;
    n--;
  }
  cout << (n > 0 ? n : 0) << endl;
  return 0;
}
