#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long bact = 1;
  long long r = 0;
  int i = 0;
  bool si = false;
  while (i < n) {
    if (bact > t) {
      si = true;
      break;
    }
    if (bact == t) {
      cout << n - r << endl;
      return 0;
      break;
    }
    bact *= k;
    bact += b;
    r++;
    i++;
    if (bact > t) {
      si = true;
      break;
    }
  }
  if (!si)
    cout << "0" << endl;
  else
    cout << n - r + 1 << endl;
  return 0;
}
