#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
int sgn(double x) {
  if (fabs(x) < eps) return 0;
  return 1;
}
int main() {
  int A1, A2, B1, B2, C1, C2;
  while (~scanf("%d%d%d%d%d%d", &A1, &B1, &C1, &A2, &B2, &C2)) {
    if ((A1 == 0 && B1 == 0 && C1) || (A2 == 0 && B2 == 0 && C2)) {
      printf("0\n");
      continue;
    }
    if ((A1 == 0 && B1 == 0 && C1 == 0) || (A2 == 0 && B2 == 0 && C2 == 0)) {
      printf("-1\n");
      continue;
    }
    if (B1 == 0 || B2 == 0) {
      if (B1 || B2)
        printf("1\n");
      else {
        if (C1 == 0 || C2 == 0) {
          if (C1 == C2)
            printf("-1\n");
          else
            printf("0\n");
          continue;
        }
        double p1 = (double)A1 / C1, p2 = (double)A2 / C2;
        if (sgn(p1 == p2))
          printf("-1\n");
        else
          printf("0\n");
      }
      continue;
    }
    if (A1 == 0 || A2 == 0) {
      if (A1 || A2)
        printf("1\n");
      else {
        if (C1 == 0 || C2 == 0) {
          if (C1 == C2)
            printf("-1\n");
          else
            printf("0\n");
          continue;
        }
        double p1 = (double)B1 / C1, p2 = (double)B2 / C2;
        if (sgn(p1 == p2))
          printf("-1\n");
        else
          printf("0\n");
      }
      continue;
    }
    double s1 = (double)A1 / B1;
    double s2 = (double)A2 / B2;
    if (sgn(s1 - s2) == 0) {
      double q1, q2, q3;
      q1 = (double)A1 / A2;
      q2 = (double)B1 / B2;
      if (C2 != 0) q3 = (double)C1 / C2;
      if (q1 == q2 && ((C1 == 0 && C2 == 0) || q2 == q3))
        printf("-1\n");
      else
        printf("0\n");
    } else
      printf("1\n");
  }
  return 0;
}
