# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>

# <codecell>

count1, count2, x, y = map(int, raw_input().split())

# <codecell>

limit1 = float(count1 * x)/(x - 1)

# <codecell>

limit2 = float(count2 * y)/(y - 1)

# <codecell>

if limit1 % 1.0 == 0.0:
    limit1 = limit1 -1
else:
    limit1 = int(limit1)

# <codecell>

if limit2 % 1.0 == 0.0:
    limit2 = limit2 -1
else:
    limit2 = int(limit2)

# <codecell>

print int(max(limit1, limit2))

# <codecell>


