import java.util.Scanner;


public class AboutBacteria {
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        
        long k ;
        long b ;
        long n ;
        long t ;
        long x;
        int time;
        
        while( in.hasNext() ){
            k = in.nextInt();
            b = in.nextInt();
            n = in.nextInt();
            t = in.nextInt();
            time = 0;
            x = k+b;
            
            while(true){
                if( x >= t){
                    break;
                }else{
                    time++;
                    x = k*x +b;
                }
            }
            System.out.println(n-time>0 ? ((k == 1 && b == 1 && n == t )? n-time-1 :n-time) : 0);
        }
    }
}
