#include <bits/stdc++.h>
using namespace std;
long long tre[21];
int main() {
  int k, b, n, t;
  scanf("%d%d%d%d", &k, &b, &n, &t);
  tre[0] = 1;
  for (int i = 1; i < 21; ++i) tre[i] = tre[i - 1] * 3;
  for (int i = 0; i <= n; ++i) {
    int out = n - i;
    if (out > 20) continue;
    long long use = tre[out];
    if (t >= use) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
