import java.util.Scanner;


public class p199c {
    public static void main(String[] Args){
        Scanner data = new Scanner(System.in);
        int k=data.nextInt(),b=data.nextInt(),n=data.nextInt(),t=data.nextInt();
        long rr=0,s=1;
        boolean p=false;
        int res=0;
        for(int i=0;p==false;i++){
            rr+=s*b;
            s*=k;
            res=i;
            if(rr+s>t)p=true;
        }
        System.out.println(n-res<0?0:n-res);
    }
}
