import java.io.PrintWriter;
import java.util.Scanner;


public class AboutMicrobes {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		int b = in.nextInt();
		int n = in.nextInt();
		int t = in.nextInt();
		int alpha = -1;
		for (long m = 1; m <= t && alpha < n; m = m * k + b) {
			alpha++;
		}
		PrintWriter out = new PrintWriter(System.out);
		out.println(n - alpha);
		out.flush();
	}

}
