#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
//#include <time.h>
//#include <assert.h>
//#include <windows.h>
using namespace std;
int main() {
long long l,w,x,y;
while(cin>>l>>w>>x>>y && l && w && x && y) {
if (l*w==x*y) cout<<1<<endl;
else
if ((l%x!=0)||(w%y!=0)) cout<<-1<<endl;
else cout<<l*w/(x*y)<<endl;
}
return 0;
}