#include <bits/stdc++.h>
using namespace std;
char str[100005];
int vis[26];
int k, b, n, t;
int main() {
  while (~scanf("%d%d%d%d", &k, &b, &n, &t)) {
    int cnt = 0;
    long long x = 1;
    while (cnt <= n) {
      if (x >= t) break;
      x = x * k + b;
      cnt++;
    }
    int ans;
    if (x == t)
      ans = n - cnt;
    else
      ans = n - cnt + 1;
    printf("%d\n", ans);
  }
  return 0;
}
