#include <bits/stdc++.h>
using namespace std;
int get_res(int a, int b, int c) {
  if (a == 0 && b == 0) {
    if (c == 0)
      return 2;
    else
      return 0;
  }
  return 1;
}
int points(const int a1, const int b1, const int c1, const int a2, const int b2,
           const int c2) {
  if (a1 * b2 == a2 * b1) {
    if ((a1 * c2 == a2 * c1) && (b1 * c2 == b2 * c1)) return -1;
    return 0;
  }
  return 1;
}
int main() {
  int a1, b1, c1, a2, b2, c2;
  int res1, res2;
  cin >> a1 >> b1 >> c1;
  cin >> a2 >> b2 >> c2;
  res1 = get_res(a1, b1, c1);
  res2 = get_res(a2, b2, c2);
  if (res1 == 1 && res2 == 1) {
    cout << points(a1, b1, c1, a2, b2, c2) << "\n";
  } else if (res1 == 0 || res2 == 0) {
    cout << "0\n";
  } else
    cout << "-1\n";
  return 0;
}
