#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-6;
struct POINT {
  double x;
  double y;
  POINT(double a = 0, double b = 0) {
    x = a;
    y = b;
  }
};
struct LINESEG {
  POINT s;
  POINT e;
  LINESEG(POINT a, POINT b) {
    s = a;
    e = b;
  }
  LINESEG() {}
};
struct LINE {
  double a;
  double b;
  double c;
  LINE(double d1 = 1, double d2 = -1, double d3 = 0) {
    a = d1;
    b = d2;
    c = d3;
  }
};
bool lineintersect(LINE l1, LINE l2, POINT &p) {
  double d = l1.a * l2.b - l2.a * l1.b;
  if (abs(d) < eps) return false;
  return true;
}
int equals(double a, double b) { return fabs(a - b) < eps; }
int main() {
  POINT pp;
  double a, b, c;
  double A, B, C;
  scanf("%lf%lf%lf", &a, &b, &c);
  LINE l1(a, b, c);
  scanf("%lf%lf%lf", &A, &B, &C);
  LINE l2(A, B, C);
  if (a == 0 && b == 0 && c != 0) {
    printf("0\n");
    return 0;
  }
  if (A == 0 && B == 0 && C != 0) {
    printf("0\n");
    return 0;
  }
  if (a == 0 && b == 0 && c == 0) {
    printf("-1\n");
    return 0;
  }
  if (A == 0 && B == 0 && C == 0) {
    printf("-1\n");
    return 0;
  }
  if (B == 0 && b == 0) {
    if (equals(c / a, C / A)) {
      printf("-1\n");
      return 0;
    }
  } else if (A == 0 && a == 0) {
    if (equals(c / b, C / B)) {
      printf("-1\n");
      return 0;
    }
  } else if (equals(a / a, A / A) && equals(b / a, B / A) &&
             equals(c / a, C / A)) {
    printf("-1\n");
    return 0;
  }
  bool ret = lineintersect(l1, l2, pp);
  if (ret == true)
    printf("1\n");
  else
    printf("0\n");
  return 0;
}
