X, Y, A, B = map(int, input().split())
ans = 0
while A * X <= X + B and A * X < Y:
    X *= A
    ans += 1
print(ans + (Y - 1 - X) // B)

61a5c6b2543bd24ae81d2853e159ab84f0e0891a
<mask token>

<mask token>
while A * X <= X + B and A * X < Y:
    X *= A
    ans += 1
print(ans + (Y - 1 - X) // B)

X, Y, A, B = map(int, input().split())
ans = 0
while A * X <= X + B and A * X < Y:
    X *= A
    ans += 1
print(ans + (Y - 1 - X) // B)
