import java.util.Scanner;

public class Microbs implements Runnable {
  public void run() {
    try {
      Scanner in = new Scanner(System.in);
      //BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int k = in.nextInt();
      int b = in.nextInt();
      int n = in.nextInt();
      int t = in.nextInt();
      long num = 1L;
      int s = 0;
      while (num <= t) {
        num = k * num + b;
        s++;
      }
      System.out.println(Math.max(n - s + 1, 0));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  public static void main(String[] args) {
    new Thread(new Microbs()).start();
  }
}
