// package p198A;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long k, b, n, t, a, i;
		k = sc.nextInt();
		b = sc.nextInt();
		n = sc.nextInt();
		t = sc.nextInt();
		
		a = 1;
		for(i=-1; a <= t && i < n; ++i) {
			a = k*a + b;
		}
		
		System.out.println(n-i);
	}

}