import java.util.*;
import java.math.*;

public class Main{
	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 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);
	}
}