#include <bits/stdc++.h>
long classify(long x, long y, long z) {
  if (x * x + y * y) return 2;
  if (z) return 0;
  return 3;
}
int main(void) {
  long a, b, c, d, aa, bb, cc, dd;
  long y = 2;
  scanf("%ld%ld%ld%ld%ld%ld", &a, &b, &c, &aa, &bb, &cc);
  d = classify(a, b, c);
  dd = classify(aa, bb, cc);
  switch (d * dd) {
    case 0:
      y = 0;
      break;
    case 4:
      break;
    default:
      y = -1;
      break;
  }
  if (y == 2) {
    if (a * bb != b * aa)
      y = 1;
    else {
      if (a * cc == c * aa && b * cc == c * bb)
        y = -1;
      else
        y = 0;
    }
  }
  printf("%ld\n", y);
  return 0;
}
