#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long j, n, k, b, t;
  cin >> k >> b >> n >> t;
  long long s = 1, i = 0, r;
  while (s <= t) {
    r = n - i;
    s = k * s + b;
    ++i;
  }
  if (r < 0) r = 0;
  cout << r;
  return 0;
}
