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

public class AboutBacteria {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int k = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int t = Integer.parseInt(st.nextToken());
        long x = 1;
        int time = 0;
        while (x <= t) {
            x = k*x+b;
            time++;
        }
        System.out.println(Math.max(0,n-time+1));
    }
}