#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 74, OO = 0x3f3f3f3f;
class CAboutBacteria {
 public:
  void solve(istream& cin, ostream& cout) {
    long long k, b, n, t;
    cin >> k >> b >> n >> t;
    long long m = 0, z = 1;
    for (int i = 0; i < n; i++) {
      z = (z * k) + b;
      ++m;
      if (z > t) {
        break;
      }
    }
    if (t >= z)
      m = n = 0;
    else
      --m;
    cout << n - m;
  }
};
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  CAboutBacteria solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
