import java.util.*;
public class Main {

    public static void main(String [] args){
    	     long x=1;  int cnt=0;
    	   Scanner in = new Scanner(System.in);
    	       long k = in.nextLong();
    	            long b = in.nextLong();
    	               long n = in.nextLong();
    	                  long t = in.nextLong();




    	                  while(x<t){

    	                  	x= k*x + b;
    	                  	  cnt++;


    	                  	  if(cnt==n)
    	                  	  	break;
    	                  }

    	                  if(cnt==n && x<=t)
    	                  	System.out.print("0");


    	                  	else if(x>t && cnt==n)
    	                  		System.out.print("1");


    	                  else if(x==t){




    	                  	System.out.print((n-cnt));
    	                  }


    	                  	else if(x>t)
    	                  System.out.print((n-cnt+1));
    }
}