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

public class Main5 {
public static void main(String[] args) throws IOException {
    BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
    String input="";
    input =reader.readLine();
    long k=0;
    long b=0;
    long n=0;
    long t=0;
    String []array;
    long result=0;
    long time=0;
    while(input!=null){
        result=1;
        time=0;
    array=input.split(" ");
    k=Integer.parseInt(array[0]);
    b=Integer.parseInt(array[1]);
    n=Integer.parseInt(array[2]);
    t=Integer.parseInt(array[3]);
    while(result<=t&&time<n){
        result=result*k+b;
        time++;
    }
    if(result<=t){
    System.out.println(0);
    }else
    System.out.println(n-(time-1));
    input=reader.readLine();
    }
}
}
