import java.util.*;
import static java.lang.Math.*;
public class ProblemC {
    void run() {
        Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int t = sc.nextInt();
		int z = 1;
		int T = -1;
		while (z <= t) {
			++T;
			z = k*z + b;
		}
		p("%d\n", max(n - T, 0));
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemC(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemC(args).run();
    }
}
