
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class AboutBacteria {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.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 seconds = 0;
        for (int i = 0; i < n; i++) {
            x = k * x + b;
            if(x <= t)
                seconds++;
            else
                break;
        }
        
        System.out.println(n - seconds);
    }

}
