#include <bits/stdc++.h>
int main() {
  int t;
  int a, b, c, a1, b1, c1;
  while (scanf("%d%d%d%d%d%d", &a, &b, &c, &a1, &b1, &c1) != EOF) {
    if (a == 0 && b == 0 && c == 0) {
      if (a1 == 0 && b1 == 0 && c1 == 0)
        t = -1;
      else if (a1 == 0 && b1 == 0 && c1 != 0)
        t = 0;
      else
        t = -1;
    } else if (a == 0 && b == 0 && c != 0)
      t = 0;
    else {
      if (a1 == 0 && b1 == 0 && c1 == 0)
        t = -1;
      else if (a1 == 0 && b1 == 0 && c1 != 0)
        t = 0;
      else {
        if (a == 0 && b != 0) {
          if (a1 == 0 && b1 != 0) {
            if (b * c1 == b1 * c)
              t = -1;
            else
              t = 0;
          } else
            t = 1;
        } else if (a != 0 && b == 0) {
          if (a1 != 0 && b1 == 0) {
            if (a * c1 == a1 * c)
              t = -1;
            else
              t = 0;
          } else
            t = 1;
        } else {
          if (a * b1 == a1 * b) {
            if (a * c1 == c * a1)
              t = -1;
            else
              t = 0;
          } else
            t = 1;
        }
      }
    }
    printf("%d\n", t);
  }
  return 0;
}
