#include using namespace std; long long a, b, c, d,t=0,x,y,k,z; int main() { cin >> a >> b >> c >> d; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); freopen("countnum.inp","r",stdin); freopen("countnum.out","w",stdout); x = b / c - (a - 1) / c; y = b / d - (a - 1) / d; k = (c * d) / __gcd(c, d); z = b / k - (a - 1) / k; t= b - a + 1 - x - y + z; cout << t; }