#include <bits/stdc++.h>
using namespace std;
const int M = 5e6 + 5;
const long long int mod = 1e9 + 7;
const long long int inf = 9e18;
const double pi = 3.14159265358979323846;
long long int t, n, m, x, sum, k, p, u = 0;
string s, z, ans = "";
long long int raised(long long int x, long long int v) {
  if (v == 0) return 1 % mod;
  if (v % 2 == 1) return (x * raised(x, v - 1)) % mod;
  long long int r = raised(x, v / 2);
  return (r * r) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int b, c = 0;
  cin >> k >> b >> n >> t;
  x = 1;
  while (x <= t) {
    x = k * x + b;
    c++;
  }
  cout << max(u, n - c + 1);
}
