#!/usr/bin/env python
import math

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

if k == 1:
    print max(0, int(math.ceil(n - (t - 1) / float(b))))
else:
    a = t * (k - 1) + b
    b = (k - 1) + b
    c = float(a) / float(b)
    print max(0, int(math.ceil(n - math.log(c, k))))
