import java.util.*;

public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextInt();
        long b = sc.nextInt();
        long n = sc.nextInt();
        long t = sc.nextInt();
        long z = 1;
        boolean done = false;
        for (int i = 0; i < n && !done; i++) {
            z = k * z + b;
            if (z > t) {
                done = true;
                System.out.println(n - i);
            }
        }
        if (!done)
            System.out.println(0);
    }
}