#include <bits/stdc++.h>
inline int cmp(double x, double y = 0, double tol = 1e-9) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
int main() {
  int A, B, C, D, E, F;
  std::cin >> A >> B >> C >> D >> E >> F;
  int det = A * E - D * B;
  if (det == 0) {
    if (A == 0 && D == 0) {
      if (B == 0 && C != 0 || E == 0 && F != 0)
        std::cout << 0 << std::endl;
      else if (B == 0 || E == 0)
        std::cout << -1 << std::endl;
      else if (C * E - F * B == 0)
        std::cout << -1 << std::endl;
      else
        std::cout << 0 << std::endl;
    } else if (A == 0) {
      if (C != 0)
        std::cout << 0 << std::endl;
      else
        std::cout << -1 << std::endl;
    } else if (D == 0) {
      if (F != 0)
        std::cout << 0 << std::endl;
      else
        std::cout << -1 << std::endl;
    } else {
      if (A == 0 && C != 0 || D == 0 && F != 0)
        std::cout << 0 << std::endl;
      else if (A == 0 || D == 0)
        std::cout << -1 << std::endl;
      else if (C * D - F * A == 0)
        std::cout << -1 << std::endl;
      else
        std::cout << 0 << std::endl;
    }
  } else
    std::cout << 1 << std::endl;
  return 0;
}
