#include <bits/stdc++.h>
int pan(double x, double y, double z) {
  if (x == 0 && y == 0) {
    if (z == 0)
      return 1;
    else
      return 2;
  }
  return 3;
}
int main() {
  double a1, a2, b1, b2, c1, c2;
  while (~scanf("%lf%lf%lf%lf%lf%lf", &a1, &b1, &c1, &a2, &b2, &c2)) {
    int k1, k2;
    k1 = pan(a1, b1, c1);
    k2 = pan(a2, b2, c2);
    if ((k1 == 1 && k2 != 2) || (k1 != 2 && k2 == 1)) {
      printf("-1\n");
      continue;
    }
    if (a1 == 0 && a2 == 0 && b1 != 0 && b2 != 0) {
      if (c1 / b1 == c2 / b2) {
        printf("-1\n");
        continue;
      } else {
        printf("0\n");
        continue;
      }
    }
    if (a1 != 0 && a2 != 0 && b1 == 0 && b2 == 0) {
      if (c1 / a1 == c2 / a2) {
        printf("-1\n");
        continue;
      } else
        printf("0\n");
      continue;
    }
    if (a1 != 0 && b1 != 0 && a2 != 0 && b2 != 0) {
      if (a1 / b1 == a2 / b2 && c1 / b1 == c2 / b2) {
        printf("-1\n");
        continue;
      } else if (a1 / b1 == a2 / b2) {
        printf("0\n");
        continue;
      }
    }
    if ((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0)) {
      printf("0\n");
      continue;
    }
    printf("1\n");
  }
  return 0;
}
