import java.io.*;
import java.util.*;


public class Contest1_1{
    
    public static void main(String ar[]) throws Exception { 
        
        BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tok = new StringTokenizer(buff.readLine());
        long k = Long.parseLong(tok.nextToken());
        long b = Long.parseLong(tok.nextToken());
        long n = Long.parseLong(tok.nextToken());
        long t = Long.parseLong(tok.nextToken());
        long z = 1;
        int count =0;
        if(z==t){
            System.out.println(n);
        }else {
            while(z<=t && count<=n)
            {
                z = (z*k) + b;
                count++;
            }
            System.out.println(n-count+1);  
        }
    }
}