#include <bits/stdc++.h>
using namespace std;
int main() {
  int A1, B1, C1, A2, B2, C2;
  while (cin >> A1 >> B1 >> C1 >> A2 >> B2 >> C2) {
    int ans = 0;
    if ((A1 == 0 && B1 == 0) || (A2 == 0 && B2 == 0)) {
      if ((A1 == 0 && B1 == 0 && C1 != 0) || (A2 == 0 && B2 == 0 && C2 != 0))
        ans = 0;
      else
        ans = 2;
    } else if (A2 * B1 == A1 * B2) {
      if (A1 == 0 || A2 == 0) {
        if (B1 * C2 == B2 * C1)
          ans = 2;
        else
          ans = 0;
      } else {
        if (A1 * C2 == A2 * C1)
          ans = 2;
        else
          ans = 0;
      }
    } else
      ans = 1;
    if (ans == 2)
      cout << -1 << endl;
    else if (ans == 1)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
}
