#include <bits/stdc++.h>
using namespace std;
long long n, c1, c2, x, y, b, c, ans;
int main() {
  cin >> c1 >> c2 >> x >> y;
  ans = n = c1 + c2;
  b = n / x - n / (x * y);
  if (b > c2) ans += b - c2;
  b = n / y - n / (x * y);
  if (b > c1) ans += b - c1;
  ans += ans / (x * y);
  cout << ans;
  return 0;
}
