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

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