import java.util.Scanner;
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 x = 1 ;
    	int counter = 0  ;
    	
        for (int i = 1; i <= n; i++) 
        {
            x = k * x + b ;
            
            if (x <= t)
                counter ++ ;
            else
                break;
        }
        System.out.println( n - counter ) ;
    }
}