#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = 3.14159265358979323846264338327950288419716939937511;
const double eps = 1e-10;
char ch_ch_ch[1 << 20];
string gs() {
  scanf("%s", ch_ch_ch);
  return string(ch_ch_ch);
}
string gl() {
  gets(ch_ch_ch);
  return string(ch_ch_ch);
}
inline int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
long long k, b, n, t;
long long cb[1111111];
long long pw[1111111];
long long calc(long long x) { return cb[x] + pw[x]; }
void solution() {
  cin >> k >> b >> n >> t;
  cb[0] = 0;
  cb[1] = b;
  for (int i = (2); i < (1000100); ++i) cb[i] = b + k * cb[i - 1];
  pw[0] = 1;
  for (int i = (1); i < (1000100); ++i) pw[i] = pw[i - 1] * k;
  for (int x = (0); x < (n + 1); ++x) {
    if (calc(x) <= t && calc(x + 1) > t) {
      cout << n - x << endl;
      return;
    }
  }
  cout << 0 << endl;
}
int main(int argc, char** argv) {
  solution();
  return 0;
}
