#include <bits/stdc++.h>
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
long long x, k, b, n, t, nr;
int main() {
  cin >> k >> b >> n >> t;
  x = 1;
  while (x <= t) {
    nr++;
    x = x * k + b;
  }
  cout << ((n - nr + 1 > 0) ? n - nr + 1 : 0);
  return 0;
}
