//package contest_125_div2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
/**
 * Date     : Jul 8, 2012
 * Time     : 1:37:38 PM
 * Email    : denys.astanin@gmail.com
 */

public class C {
	public static void main(String[] args) throws IOException {
		new C().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;

	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_125_div2/C.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int k = nextInt();
		int b = nextInt();
		int n = nextInt();
		int t = nextInt();
		
	    long result=1;
	    long time=0;
		while(result <= t && time < n){
	        result = result * k+b;
	        time++;
	    }
	    if(result<=t){
	    	out.println(0);
	    } else {
	    	out.println(n-(time-1));
	    }
		out.flush();
		out.close();
	}
}
