#include <iostream>
#include <algorithm>
#include <cmath>
using LL = long long;
using namespace std;
LL a,b,x,y;
LL ceil_div(LL n,LL m)
{
if(n <= 0) return 0;
return (n + m -1) / m;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
if(!(cin >> a >> b >> x >> y)) return 0;
LL min_ops{-1};//最小操作数
LL maxk = max((ceil_div(a, y)) , (ceil_div(b,y)));
for(int i = 0; i <= maxk ;i++)
{
LL rem_a = a - i * y;
LL rem_b = b - i * y;
LL ops_a = ceil_div(rem_a , x);
LL ops_b = ceil_div(rem_b , x);
LL ops = ops_a + ops_b + i;
if(ops < min_ops || min_ops == -1)
min_ops = ops;
if(rem_a <= 0 && rem_b <= 0)
break;
}
cout << min_ops << "\n";
return 0;
}