import math

def solve():
  input = raw_input().split()
  k = int(input[0])
  b = int(input[1])
  n = int(input[2])
  t = int(input[3])
  curr = 1
  time = 0
  while curr < t:
    curr = k * curr + b
    time+=1
  if curr > t:
    time-=1
  if time > n:
    time = n
  print n-time

solve()