
import java.util.Scanner;

public class AboutBacteria {
    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);
        int k = read.nextInt();
        int b = read.nextInt();
        int n = read.nextInt();
        int t = read.nextInt();
        int current = 1;
        int sec = 0;
        while (current <= t) {
            current = k * current + b;
            sec++;
        }
        if (n + 1 - sec < 0)
            System.out.println(0);
        else
            System.out.println(n + 1 - sec);
    }
}
