import java.util.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{
	
	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//
//	static long sum=0;
	//int a,b,c;
	//1000000007 (10^9+7)
	//static int mod = 1000000007;
   // static int d[][];
	//static int dx[]={1,-1,0,0};
	//static int dy[]={0,0,1,-1};

	
public  static void main(String[] args) {
	
   Scanner sc =new Scanner(System.in);
   while(sc.hasNext()){
		 // =ni(sc)
	   //long sum=0;
		//  int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt(),a=0;
	long k=sc.nextLong(),b=sc.nextLong(),n=sc.nextLong(),t=sc.nextLong();
	
if(k==1)	for(int i=0;true;i++){
	
		if( (double)(1+n*b-t)/(double)b <= i ){System.out.println(i);return;}
		
	}
	   
	for(int i=0;true;i++){
		double P=pow(k,n-i);
		if(P+b*(P-1)/(k-1)  <=t ){System.out.println(i);return;}
		
	}
	   
		
   }

}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}


}

/*
class pair {
    int v,vv;
	pair(int v,int vv){
		this.v=v;
	    this.vv=vv;
	} 

}*/

