#include <bits/stdc++.h>
using namespace std;
long long int bnm(long long int n, long long int k) {
  long long int res = 1;
  if (n < k) return 0;
  if (k > n - k) k = n - k;
  for (long long int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int PowMod(long long int n) {
  long long int ret = 1;
  long long int a = 2;
  while (n > 0) {
    if (n & 1) ret = ret * a % 998244353;
    a = a * a % 998244353;
    n >>= 1;
  }
  return ret;
}
void ghost() {
  double n, i = 0, k = 1, q, y = 0, w = 0, x = 0, m = 0, l = 0, j = 0, a = 0,
            b = 0, c = 0;
  cin >> a >> b >> c;
  cin >> w >> x >> y;
  if ((a == 0 && b == 0 && c == 0) || (w == 0 && x == 0 && y == 0)) {
    if ((a == 0 && b == 0) && (w == 0 && x == 0)) {
      if (c != 0 || y != 0) {
        cout << 0;
        return;
      }
    }
    cout << "-1";
  } else if ((a == 0 && b == 0) || (w == 0 && x == 0))
    cout << 0;
  else if (a * x - b * w == 0) {
    if (c == 0 && y == 0)
      cout << "-1";
    else if (c == 0 || y == 0)
      cout << 0;
    else if ((a * y == c * w) && (b * y == x * c))
      cout << "-1";
    else
      cout << 0;
  } else
    cout << 1;
}
signed main() {
  long long int test = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (test--) ghost();
  return 0;
}
