import java.util.Scanner;

public class AboutBacteria {

	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();
		long res = 0;
		while (true) {
			long sum = 0;
			for (long i = 0; i < res; i++) {
				sum += Math.pow(k, 0);
			}
			sum = sum * b;
			sum += Math.pow(k, res);
			if (sum > t) {
				res = n - (res - 1);
				if (res <= 0)
					res = 0;
				break;
			}
			res++;
		}
		System.out.println((res));
	}
}
