#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  double A1, A2, B1, B2, C1, C2;
  cin >> A1 >> B1 >> C1;
  cin >> A2 >> B2 >> C2;
  if ((A1 == B1) && (A1 == 0.0)) {
    if (C1 != 0.0) {
      cout << 0 << endl;
      return 0;
    }
  }
  if ((A2 == B2) && (A2 == 0.0)) {
    if (C2 != 0.0) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (A1 == A2 && B1 == B2 && C1 == C2) {
    cout << -1 << endl;
    return 0;
  }
  if ((A2 == B2) && (A2 == 0.0) && (C2 == 0.0)) {
    cout << -1 << endl;
    return 0;
  }
  if ((A1 == B1) && (A1 == 0.0) && (C1 == 0.0)) {
    cout << -1 << endl;
    return 0;
  }
  if ((A1 == A2) && (A1 == 0.0)) {
    if ((B1 / B2 == C1 / C2) || ((C1 == C2) && (C1 == 0))) {
      cout << -1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  if ((B1 == B2) && (B1 == 0.0)) {
    if ((A1 / A2 == C1 / C2) || ((C1 == C2) && (C1 == 0))) {
      cout << -1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  if (((double)A1 / (double)A2) == ((double)B1 / (double)B2)) {
    if (((C1 == C2) && (((A1 > 0) && (A2 > 0)) || ((A1 < 0) && (A2 < 0)))) ||
        (C1 / C2 == B1 / B2)) {
      cout << -1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  cout << 1 << endl;
  return 0;
}
