import java.util.Scanner;

public class AboutBacteria199C {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k, b, n, t;
		k = in.nextInt();
		b = in.nextInt();
		n = in.nextInt();
		t = in.nextInt();
		long z = 1;
		int a = 0;
		while (z <= t) {
			a++;
			z = z * k + b;
		}
		int m = n - a + 1;
		if (m < 0)
			m = 0;
		System.out.println(m);
	}
}
