import java.util.Scanner;

public class N4_CF_199C {
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int k = in.nextInt(), b = in.nextInt(), n = in.nextInt(), t = in
        .nextInt();
    long z = 1;
    for(int i = 0 ; i < n ; i++)
    {
        z = z * k * 1l + b;
        if( t <= z - 1)
        {
        System.out.println(n - i);
        return;
        }
    }
    System.out.println(0);
    }
   
}
