#include <bits/stdc++.h>
using namespace std;
long long lol[1000001];
int main() {
  int k, b, n, t;
  scanf("%d%d%d%d", &k, &b, &n, &t);
  lol[0] = 1;
  int lim = 1;
  for (int i = 1; i < 1000001; ++i) {
    lol[i] = lol[i - 1] * k;
    if (lol[i] > 1000000) break;
    lim++;
  }
  int low = 0, hig = n;
  while (low != hig) {
    int i = (low + hig) / 2;
    int r = n - i;
    if (r >= lim) low = i + 1;
    long long use = 0;
    for (int j = 0; j < r; ++j) {
      use += lol[j] * b;
    }
    use += lol[r];
    use -= t;
    if (use <= 0) {
      hig = i;
    } else
      low = i + 1;
  }
  printf("%d\n", low);
  return 0;
}
