#include <bits/stdc++.h>
using namespace std;
int main() {
  int a1, a2, b1, b2, c1, c2;
  while (scanf("%d%d%d%d%d%d", &a1, &b1, &c1, &a2, &b2, &c2) != EOF) {
    if (a1 == 0 && b1 == 0 && c1 != 0) {
      printf("0\n");
      continue;
    }
    if (a2 == 0 && b2 == 0 && c2 != 0) {
      printf("0\n");
      continue;
    }
    if ((a1 == 0 && b1 == 0 && c1 == 0) || (a2 == 0 && b2 == 0 && c2 == 0)) {
      printf("-1\n");
      continue;
    }
    if (a1 == 0 && a2 == 0) {
      if (c1 * b2 == c2 * b1) {
        printf("-1\n");
      } else {
        printf("0\n");
      }
      continue;
    }
    if (b1 == 0 && b2 == 0) {
      if (c1 * a2 == c2 * a1) {
        printf("-1\n");
      } else {
        printf("0\n");
      }
      continue;
    }
    if (a1 == 0 && b1 != 0) {
      printf("1\n");
      continue;
    }
    if (a1 != 0 && b1 == 0) {
      printf("1\n");
      continue;
    }
    if (a2 == 0 && b2 != 0) {
      printf("1\n");
      continue;
    }
    if (a2 != 0 && b2 == 0) {
      printf("1\n");
      continue;
    }
    if (a1 * b2 == a2 * b1) {
      if (fabs(c1 * 1.0 / b1 - c2 * 1.0 / b2) < 1e-8) {
        printf("-1\n");
      } else {
        printf("0\n");
      }
    } else {
      printf("1\n");
    }
  }
  return 0;
}
