import java.util.*;
import java.io.*;
import java.math.*;
public class Euler {
	
    public static void main(String[] args){
        FastReader in = new FastReader();
        PrintWriter o = new PrintWriter(System.out);
        
        double k = in.nextInt();
        double b = in.nextInt();
        double n = in.nextInt();
        double t = in.nextInt();
        
        if (k != 1) {
			  double val = ( (t * (k - 1)) + b) / (k + b - 1);
        
              double val1 = Math.log(val) / Math.log(k);
        
              n -= val1;
              
              if (Math.ceil(n) <= 0) {
				  o.println("0");
			  }else {
				  o.println((long) Math.ceil(n));
			  }
               
		} else {
			
			double val = n * b - t + 1.0;
			
			o.println(Math.max(0, (long) Math.ceil(val/b)));
			
			
			
		}
       
        
        
        
        
        
        o.close();
        o.flush();
        return;
    }
    
    
    static final Random random=new Random();
 
    static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
    
   
	
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
 
        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
 
}
