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 {
		long k, b, n, t, m, zm = 1;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		k = Integer.parseInt(st.nextToken());
		b = Integer.parseInt(st.nextToken());
		n = Integer.parseInt(st.nextToken());
		t = Integer.parseInt(st.nextToken());
		
		for (m = 0; m < n && zm < t; ++m)
	        zm = k * zm + b;
	    if (zm > t)
	        m--;
	    
	    System.out.println(n - m);
	}

}
