//coded by : ariefianto17 | Reza Ariefianto

import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
	public static void main (String[]args)
	{
		Scanner read = new Scanner (new BufferedInputStream (System.in));
		long temp=1;
		int k = read.nextInt();
		int b = read.nextInt();
		int n = read.nextInt();
		int t = read.nextInt();

		while(temp<=t)
		{
			temp = temp*k + b;
			n--;
		}

		System.out.println(Math.max(0,n+1));
	}
}