#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
const long long mod = 1000000007;
const double eps = 1e-7;
const long long INF = 1000000000000000;
int main() {
  int a1, b1, c1, a2, b2, c2;
  cin >> a1 >> b1 >> c1;
  cin >> a2 >> b2 >> c2;
  if (a1 == 0 && b1 == 0 && c1 != 0) {
    cout << 0;
    return 0;
  }
  if (a2 == 0 && b2 == 0 && c2 != 0) {
    cout << 0;
    return 0;
  }
  if (a1 * b2 - a2 * b1 == 0) {
    int d = 1;
    for (int(i) = (1); (i) < (111); ++(i))
      if (a1 % i == 0 && b1 % i == 0 && c1 % i == 0) d = i;
    a1 /= d;
    b1 /= d;
    c1 /= d;
    d = 1;
    for (int(i) = (1); (i) < (111); ++(i))
      if (a2 % i == 0 && b2 % i == 0 && c2 % i == 0) d = i;
    a2 /= d;
    b2 /= d;
    c2 /= d;
    if ((a1 == a2 && b1 == b2 && c1 == c2) || (a1 == 0 && b1 == 0 && c1 == 0) ||
        (a2 == 0 && b2 == 0 && c2 == 0) ||
        (a1 == -a2 && b1 == 0 && b2 == 0 && c1 == -c2 && a1 != 0) ||
        (a1 == 0 && a2 == 0 && b1 == -b2 && c1 == -c2 && b1 != 0) ||
        (a1 == -a2 && b1 == -b2 && c1 == -c2 && a1 != 0 && b1 != 0))
      cout << -1;
    else
      cout << 0;
  } else
    cout << 1;
  return 0;
}
