#include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) typedef long long ll; #define MIN(a, b) ((a)>(b)? (b): (a)) #define MAX(a, b) ((a)<(b)? (b): (a)) #define LINF 9223300000000000000 #define INF 2140000000 #define MOD 1000000007 using namespace std; int main(int argc, char* argv[]) { long a,b; scanf("%ld%ld", &a, &b); if(a==b) { printf("%ld\n", a); } else { long e=MAX(a,b); long d=MAX(a,b)-MIN(a,b); if(2*e%d==0) { printf("%ld\n", d); } else { printf("-1\n"); } } return 0; }