#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
long long n, a, b, t;
int main() {
  ios::sync_with_stdio(false);
  cin >> a >> b >> n >> t;
  long long x = 1;
  while (x * a + b <= t) x = x * a + b, n--;
  cout << max(n, (long long)0) << endl;
  return 0;
}
