#include <bits/stdc++.h>
int main() {
  int a1, a2, b1, b2, c1, c2;
  int ans;
  double norm;
  scanf("%d %d %d %d %d %d", &a1, &b1, &c1, &a2, &b2, &c2);
  if (a2 * b1 - a1 * b2 == 0) {
    if (a2 == 0 && b2 == 0) {
      ans = (c2 == 0) ? -1 : 0;
      if (a1 == 0 && b1 == 0 && c1 != 0) ans = 0;
    } else {
      norm = hypot(a1, b1) / hypot(a2, b2);
      if (a1 != 0 && fabs(a2 * norm - a1) > 1e-9 || fabs(b2 * norm - b1) > 1e-9)
        norm *= -1;
      ans = (fabs(norm * c2 - c1) < 1e-9) ? -1 : 0;
    }
  } else
    ans = 1;
  printf("%d\n", ans);
  return 0;
}
