import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long ct1 = in.nextLong();
        long ct2 = in.nextLong();
        long x = in.nextLong();
        long y = in.nextLong();
        HashSet<Long> q = new HashSet();
        int con = 1;
        q.add(y);
        for (long i = 1; con < ct1; i++) {
            int f = q.size();
            if (i % x != 0) {
                q.add(i);
                if (q.size() != f) {
                    con++;
                }
            }
        }
        con = 1;
        q.add(x);
        for (long i = 1; con < ct2; i++) {
            int f = q.size();
            if (i % y != 0) {
                q.add(i);
                if (q.size() != f) {
                    con++;
                }
            }
        }
        Iterator m = q.iterator();
        String h = "";
        while (m.hasNext()) {
            h = m.next() + "";
        }
        System.out.println(h);
    }
}
