#include <bits/stdc++.h>
using namespace std;
long long k, b, n, t, s1, s2, s3, ma;
int ans;
int main() {
  cin >> k >> b >> n >> t;
  if (k != 1) {
    ma = k * t - t;
    s1 = k;
    s2 = b - 1;
    s3 = b;
    ans = n;
    for (; ma >= s1 + s2 - s3;) {
      s1 *= k;
      s2 *= k;
      ans--;
      if (ans == -1) break;
    }
    cout << ans + 1 << endl;
  } else {
    ma = 1 + n * b - t;
    ans = ma / b + ((ma % b) != 0);
    if (ans < 0) ans = 0;
    cout << ans << endl;
  }
}
