#include <bits/stdc++.h>
using namespace std;
const double EXP = 1e-9;
const int INF = 0x3f3f3f3f;
const long long MINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
int main() {
  std::ios::sync_with_stdio(false);
  int a, b, c;
  int d, e, f;
  cin >> a >> b >> c;
  cin >> d >> e >> f;
  if ((a == 0 && b == 0 && c != 0) || (d == 0 && e == 0 && f != 0))
    cout << "0" << endl;
  else if ((a == 0 && b == 0 && c == 0) || (d == 0 && e == 0 && f == 0))
    cout << "-1" << endl;
  else {
    if (a == 0) {
      if (d == 0) {
        if (b == 0 || e == 0) {
          cout << "-1" << endl;
        } else {
          if (c * e == b * f)
            cout << "-1" << endl;
          else
            cout << "0" << endl;
        }
      } else
        cout << "1" << endl;
    } else {
      if (d == 0)
        cout << "1" << endl;
      else {
        if (b == 0 && e == 0) {
          if (c * d == a * f)
            cout << "-1" << endl;
          else
            cout << "0" << endl;
        } else {
          if (a * e != b * d)
            cout << "1" << endl;
          else {
            if (c * e == b * f)
              cout << "-1" << endl;
            else
              cout << "0" << endl;
          }
        }
      }
    }
  }
  return 0;
}
