#include <bits/stdc++.h>
using namespace std;
double a, b, c;
double d, e, f;
int main() {
  cin >> a >> b >> c >> d >> e >> f;
  if ((!a && !b && c) || (!d && !e && f)) {
    printf("0");
    return 0;
  }
  if ((!a && !b && !c) || (!d && !e && !f)) {
    printf("-1");
    return 0;
  }
  if (b == 0 && e == 0) {
    if (a && d) {
      double pp = c / a;
      double qq = f / d;
      if (fabs(pp - qq) < 1e-6) {
        printf("-1");
      } else
        printf("0");
    }
    return 0;
  }
  if (a == 0 && d == 0) {
    if (b && e) {
      double pp = c / b;
      double qq = f / e;
      if (fabs(pp - qq) < 1e-6) {
        printf("-1");
      } else
        printf("0");
    }
    return 0;
  }
  if ((a == 0 && d) || (d == 0 && a)) {
    printf("%d", 1);
    return 0;
  }
  if ((b == 0 && e) || (e == 0 && d)) {
    printf("%d", 1);
    return 0;
  }
  double p = a / b;
  double q = d / e;
  if (p == q) {
    double pp = c / a;
    double qq = f / d;
    if (fabs(pp - qq) < 1e-6) {
      printf("-1");
    } else
      printf("0");
    return 0;
  }
  if (p != q) {
    printf("1");
    return 0;
  }
}
