#include <bits/stdc++.h>
int main() {
  double a[2], b[2], c[2];
  int r(1);
  for (int i(0); i < 2; ++i) {
    std::scanf("%lf%lf%lf", &a[i], &b[i], &c[i]);
    if (a[i] != 0) {
      b[i] /= a[i];
      c[i] /= a[i];
      a[i] = 1.0;
    } else {
      if (b[i] != 0) {
        c[i] /= b[i];
        b[i] = DBL_MAX;
      }
    }
  }
  for (int i(0); i < 2; ++i) {
    if (a[i] == 0 && b[i] == 0) {
      r = -1;
      for (int j(0); j < 2; ++j) {
        if (a[j] == 0 && b[j] == 0) {
          if (c[j] != 0) r = 0;
        }
      }
      goto E;
    }
  }
  if (b[0] == b[1]) {
    if (c[0] == c[1])
      r = -1;
    else
      r = 0;
  }
E:
  std::printf("%d\n", r);
  return 0;
}
