#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:16000000")
#pragma warning(disable : 4996)
const int inf = 1 << 25;
const double eps = 1e-9;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int range(vector<vector<int> > a) {
  for (int j = (0); j < ((int)a[0].size()); ++j)
    if (a[0][j] != 0 && a[1][j] != 0) {
      int b[2] = {a[1][j], a[0][j]};
      for (int i = (0); i < (2); ++i)
        for (int k = (0); k < ((int)a[i].size()); ++k) a[i][k] *= b[i];
      for (int j = (0); j < ((int)a[0].size()); ++j) a[0][j] -= a[1][j];
      goto out;
    }
out:;
  int r = a.size();
  for (int i = (0); i < ((int)a.size()); ++i)
    if (a[i] == vector<int>(a[i].size(), 0)) --r;
  return r;
}
int main() {
  vector<int> a(3), b(3);
  for (int i = (0); i < (3); ++i) cin >> a[i];
  for (int i = (0); i < (3); ++i) cin >> b[i];
  vector<vector<int> > A(2, vector<int>(2));
  for (int i = (0); i < (2); ++i) {
    A[0][i] = a[i];
    A[1][i] = b[i];
  }
  vector<vector<int> > Ex(2, vector<int>(3));
  for (int i = (0); i < ((int)A.size()); ++i)
    for (int j = (0); j < ((int)A[i].size()); ++j) Ex[i][j] = A[i][j];
  Ex[0][2] = a[2];
  Ex[1][2] = b[2];
  int rA = range(A);
  int rEx = range(Ex);
  if (rA == rEx) {
    if (rA < 2)
      printf("-1");
    else
      printf("1");
  } else
    printf("0");
  return 0;
}
