#include <bits/stdc++.h>
using namespace std;
int A1, A2, B1, B2, C1, C2;
bool f1() { return (A1 * B2 == A2 * B1); }
bool f2() { return (B1 * C2 == B2 * C1); }
bool f3() { return (A1 * C2 == A2 * C1); }
int main() {
  cin >> A1 >> B1 >> C1;
  cin >> A2 >> B2 >> C2;
  if (A1 == 0 && B1 == 0 && C1 != 0) {
    cout << "0";
    return 0;
  }
  if (A2 == 0 && B2 == 0 && C2 != 0) {
    cout << "0";
    return 0;
  }
  if (f1()) {
    if (f2() && f3())
      cout << "-1";
    else
      cout << "0";
  } else
    cout << "1";
  return 0;
}
