import java.io.*;

public class C {
    public static void main(String[] args) throws Exception {
        new C().solve();
    }

    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = in.readLine().split(" ");
        int k, b, n, t;
        k = Integer.parseInt(sp[0]);
        b = Integer.parseInt(sp[1]);
        n = Integer.parseInt(sp[2]);
        t = Integer.parseInt(sp[3]);

        if (t == 1) {
            System.out.println(n);
            return;
        }

        long now = 1;
        int sec;
        for (sec = 1;; sec++) {
            now = k * now + b;
            if (now > t) {
                System.out.println(n - sec + 1);
                return;
            } else if (sec >= n) {
                System.out.println(0);
                return;
            }
        }
    }
}
