#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long a1, b1, c1, a2, b2, c2;
  cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  if (a1 == b1 && a1 == 0) {
    if (c1 == 0) {
      if (a2 == b2 && a2 == 0) {
        if (c2 == 0) {
          cout << "-1\n";
          return 0;
        } else {
          cout << "0\n";
          return 0;
        }
      } else {
        cout << "-1\n";
        return 0;
      }
    } else {
      cout << "0\n";
      return 0;
    }
  }
  if (a1 * b2 == b1 * a2) {
    if (a1 * c2 == a2 * c1 && b1 * c2 == c1 * b2) {
      cout << "-1\n";
    } else {
      cout << "0\n";
    }
  } else {
    cout << "1\n";
  }
  return 0;
}
