#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  long long k, b, n, t, z;
  while (cin >> k >> b >> n >> t) {
    int res;
    long long temp, temp_1;
    if (k == 1) {
      if ((n * b + 1 - t) / b)
        ;
      temp = n * b + 1 - t;
      if (temp <= 0)
        res = 0;
      else {
        if (temp % b == 0)
          res = temp / b;
        else
          res = temp / b + 1;
      }
    } else {
      temp = t * k - t + b;
      temp_1 = k - 1 + b;
      long long now = k - 1 + b;
      int m = 0;
      while (m <= n) {
        if (now > temp) {
          break;
        } else if (now == temp) {
          m++;
          break;
        } else {
          m++;
          now = now * k;
        }
      }
      --m;
      m = max(0, m);
      res = n - m;
    }
    cout << res << endl;
  }
  return 0;
}
