#include <bits/stdc++.h>
using namespace std;
using namespace std;
int get_type(int a, int b, int c) {
  if (a == 0 && b == 0 && c != 0) return 0;
  if (a == 0 && b == 0 && c == 0) return -1;
  if (a == 0) return 1;
  if (b == 0) return 2;
  return 3;
}
int main() {
  int a1, b1, c1, a2, b2, c2;
  cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  int t1 = get_type(a1, b1, c1);
  int t2 = get_type(a2, b2, c2);
  if (t1 == 0 || t2 == 0)
    cout << "0";
  else if (t1 == -1 || t2 == -1)
    cout << "-1";
  else if (t1 != t2)
    cout << "1";
  else {
    if (t1 == 1) {
      if (c1 * b2 == c2 * b1)
        cout << "-1";
      else
        cout << "0";
    } else if (t1 == 2) {
      if (c1 * a2 == c2 * a1)
        cout << "-1";
      else
        cout << "0";
    } else {
      if (b1 * a2 != a1 * b2)
        cout << "1";
      else {
        if (c1 * b2 == c2 * b1)
          cout << "-1";
        else
          cout << "0";
      }
    }
  }
  return 0;
}
