#include <bits/stdc++.h>
void swap3(int& a, int& b, int& c, int& x, int& y, int& z) {
  std::swap(a, x);
  std::swap(b, y);
  std::swap(c, z);
}
int main() {
  int a1, b1, c1, a2, b2, c2;
  std::cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  if (a1 == 0 && a2 == 0) {
    if (b1 == 0 && b2 == 0) {
      if (c1 == 0 && c2 == 0) {
        std::cout << "-1";
        return 0;
      }
      std::cout << 0;
      return 0;
    } else if (b1 == 0 || b2 == 0) {
      if (b2 == 0) swap3(a1, b1, c1, a2, b2, c2);
      if (c1 == 0) {
        std::cout << "-1";
        return 0;
      }
      std::cout << 0;
      return 0;
    } else {
      if (abs((1.0 * c1) / b1 - (1.0 * c2) / b2) < 0.00001)
        std::cout << -1;
      else
        std::cout << 0;
      return 0;
    }
  } else if (a1 == 0 || a2 == 0) {
    if (a2 == 0) swap3(a1, b1, c1, a2, b2, c2);
    if (b1 == 0) {
      if (c1 == 0)
        std::cout << "-1";
      else
        std::cout << 0;
      return 0;
    } else {
      std::cout << 1;
      return 0;
    }
  } else {
    const double b1n = (1.0 * b1) / a1;
    const double c1n = (1.0 * c1) / a1;
    const double b2n = (1.0 * b2) / a2;
    const double c2n = (1.0 * c2) / a2;
    if (abs(b1n - b2n) < 0.00001 && abs(c1n - c2n) < 0.00001)
      std::cout << "-1";
    else if (abs(b1n - b2n) < 0.0001)
      std::cout << 0;
    else
      std::cout << 1;
  }
  return 0;
}
