#include <bits/stdc++.h>
using namespace std;
int k, n, b, t;
int main() {
  while (~scanf("%d%d%d%d", &k, &b, &n, &t)) {
    int ret = n;
    long long te = 1;
    if (k == 1) {
      long long last = 1 + (long long)n * b;
      long long now = t;
      ret = 0;
      while (1) {
        if (now >= last) break;
        now += b;
        ret++;
      }
    } else {
      while (1) {
        if (te * (k - 1 + b) > (long long)(k - 1) * t + b) break;
        te *= k;
        ret--;
      }
      ret = max(0, ret + 1);
    }
    cout << ret << endl;
  }
}
