#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t, i, z, big = 1000000000, x = 1, dk, j;
bool tt = true;
int main() {
  cin >> k >> b >> n >> t;
  i = n;
  x = 1;
  if (t == 1) {
    cout << n;
    return 0;
  }
  while (x <= t) {
    dk = 1;
    i--;
    if (i + 1 < 0) break;
    x = 0;
    if (k == 1)
      x = 1 + (n - i) * b;
    else {
      for (j = 0; j < n - i; j++) {
        x += b * dk;
        dk *= k;
      }
      x += dk;
    }
  }
  if (i + 1 < 0)
    cout << 0;
  else
    cout << i + 1;
  return 0;
}
