#!/usr/bin/env python
import math

def calc(k, b, n, t):
    if k == 1:
        return t + b * n
    a = k ** n
    return a * t + b * (a - 1) / (k - 1)

(k, b, n, t) = [int(i) for i in raw_input().split()]

z = calc(k, b, n, 1)
if k == 1:
    try:
        print max(int(math.ceil((z - t) / (b * 1.0))), 0)
    except:
        print 0
else:
    try:
        a = z * (k - 1) + 1.0
    except:
        a = (k - 1) * 2
    b = t * (k - 1) + 1.0
    c = a / b
    print max(int(math.ceil(math.log(c, k))), 0)
