#include <bits/stdc++.h>
using namespace std;
typedef struct line {
  int k;
  int b;
  long double x;
} line;
bool com(line l1, line l2) {
  if (l1.x < l2.x)
    return true;
  else
    return false;
}
int main() {
  long long k, b, n, t;
  cin >> k >> b >> n >> t;
  long long x = 1;
  int t1 = 0;
  while (x < t) {
    x = k * x + b;
    t1++;
  }
  if (x != t) t1--;
  if (t1 < n) {
    cout << n - t1;
  } else
    cout << 0;
  return 0;
}
