#include <bits/stdc++.h>
using namespace std;
double mod(double a) { return (a > 0 ? a : (-a)); }
long min(long int a, long int b) { return (a) > (b) ? (b) : (a); }
long max(long int a, long int b) { return (a) > (b) ? (a) : (b); }
bool sortbyff(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first < b.first);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  long long n, k, l = 0, r = 0, i, iprev, j, flag = 0, e, t, sum = 0, ans = 0,
                  b, c, nine = 1000000007 - 7, q, p, x, z = 1;
  double avg = 0.0, eps = 0.000001;
  cin >> k >> b >> n >> x;
  while (k * z + b <= x) {
    z = k * z + b;
    n--;
  }
  cout << (n < 0 ? 0 : n);
  return 0;
}
