#include <bits/stdc++.h>
using namespace std;
void run() {
  int a1, b1, c1;
  scanf("%d%d%d", &a1, &b1, &c1);
  int a2, b2, c2;
  scanf("%d%d%d", &a2, &b2, &c2);
  if (a1 == 0) {
    swap(a1, a2);
    swap(b1, b2);
    swap(c1, c2);
  }
  if (a1 != 0) {
    if (a2 != 0) {
      int x = a1, y = -a2;
      a2 = x * a2 + y * a1, b2 = x * b2 + y * b1, c2 = x * c2 + y * c1;
      assert(a2 == 0);
    }
    printf("%d\n", b2 == 0 && c2 == 0 ? -1 : b2 == 0 ? 0 : 1);
  } else {
    if (b1 == 0) {
      swap(b1, b2);
      swap(c1, c2);
    }
    if (b1 != 0) {
      if (b2 != 0) {
        int x = b1, y = -b2;
        a2 = x * a2 + y * a1, b2 = x * b2 + y * b1, c2 = x * c2 + y * c1;
        assert(b2 == 0);
      }
      printf("%d\n", c2 == 0 ? -1 : 0);
    } else {
      printf("%d\n", c1 == 0 && c2 == 0 ? -1 : 0);
    }
  }
}
int main() {
  run();
  return 0;
}
