#include <bits/stdc++.h>
using namespace std;
int a1, b1, c1;
int a2, b2, c2;
int ans;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin >> a1 >> b1 >> c1;
  cin >> a2 >> b2 >> c2;
  if (a1 * a2 != 0) {
    int g = gcd(a1, a2);
    if ((b1 * a2 == a1 * b2) && (c1 * a2 == c2 * a1)) {
      cout << -1 << endl;
      return 0;
    }
    if ((b1 * a2 == a1 * b2) && (c1 * a2 != c2 * a1)) {
      cout << 0 << endl;
      return 0;
    }
    if (b1 * a2 != a1 * b2) {
      cout << 1 << endl;
      return 0;
    }
  }
  if (a1 == 0 && b1 == 0 && c1 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (a2 == 0 && b2 == 0 && c2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (a1 == 0 && a2 == 0) {
    if (b1 == 0 && c1 == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (b2 == 0 && c2 == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (c1 * b2 == c2 * b1) {
      cout << -1 << endl;
      return 0;
    }
    cout << 0 << endl;
    return 0;
  }
  if (a1 == 0 && a2 != 0) {
    if (b1 == 0 && c1 == 0) {
      cout << -1 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  if (a1 != 0 && a2 == 0) {
    if (b2 == 0 && c2 == 0) {
      cout << -1 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
}
