import java.io.PrintWriter;
import java.util.Scanner;


public class TaskC {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskC task = new TaskC();
        task.read();
        task.write();
    }


    long n, k, b, t;
    
    public void read() {
        Scanner in = new Scanner(System.in);
        k = in.nextLong();
        b = in.nextLong();
        n = in.nextLong();
        t = in.nextLong();
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        long cur = 1;
        int i = 0;
        long p = -1;
        if (t == 1){
            out.println(n);  
        }else{
        for (i = 0; i <= n; cur = k * cur + b, i++){
            if (cur > t){
                p = i;
                break;
            }
        }
        if (p == -1){
            out.println(0);
        }else{
            out.println(n - (p - 1));
        }}
        
        out.close();
    }
}