#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9;
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
int main() {
  long long k, b, n, t, x, y, p = 0;
  cin >> k >> b >> n >> t;
  if (k == 1) {
    x = 1 + n * b - t;
    y = x / b;
    if (x % b > 0) y++;
    if (y < 0) y = 0;
    cout << y << endl;
    return 0;
  }
  x = t * (k - 1) + b;
  y = k + b - 1;
  if (x % y > 0) p = -1;
  if (x < y) p = 0;
  x = x / y;
  while (x > 1) {
    p++;
    x = x / k;
  }
  p = n - p;
  if (p < 0) p = 0;
  cout << p << endl;
  return 0;
}
