#include <bits/stdc++.h>
using namespace std;
int panduan(double x, double y, double z) {
  if (x == 0 && y == 0) {
    if (z == 0)
      return 1;
    else
      return 2;
  }
  return 3;
}
int main() {
  double a1, a2, b1, b2, c1, c2;
  int k1, k2;
  while (cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2) {
    k1 = panduan(a1, b1, c1);
    k2 = panduan(a2, b2, c2);
    if ((k1 == 1 && k2 != 2) || (k1 != 2 && k2 == 1)) {
      cout << -1 << endl;
      continue;
    }
    if (a1 == 0 && a2 == 0 && b1 != 0 && b2 != 0) {
      if (c1 / b1 == c2 / b2) {
        cout << -1 << endl;
        continue;
      } else {
        cout << 0 << endl;
        continue;
      }
    }
    if (a1 != 0 && a2 != 0 && b1 == 0 && b2 == 0) {
      if (c1 / a1 == c2 / a2) {
        cout << -1 << endl;
        continue;
      } else
        cout << 0 << endl;
      continue;
    }
    if (a1 != 0 && b1 != 0 && a2 != 0 && b2 != 0) {
      if (a1 / b1 == a2 / b2 && c1 / b1 == c2 / b2) {
        cout << -1 << endl;
        continue;
      } else if (a1 / b1 == a2 / b2) {
        cout << 0 << endl;
        continue;
      }
    }
    if ((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0)) {
      cout << 0 << endl;
      continue;
    }
    cout << 1 << endl;
  }
  return 0;
}
