#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int a1, b1, c1;
int a2, b2, c2;
int check() {
  if (a1 == 0 && b1 == 0) {
    if (c1 != 0) return 0;
    if (a2 == 0 && b2 == 0) {
      if (c2 != 0) return 0;
      return -1;
    }
    return -1;
  } else if (a2 == 0 && b2 == 0) {
    if (c2 != 0) return 0;
    return -1;
  }
  int g = gcd(gcd(abs(a1), abs(b1)), abs(c1));
  a1 /= g;
  b1 /= g;
  c1 /= g;
  if (a1 < 0)
    a1 = -a1, b1 = -b1, c1 = -c1;
  else if (a1 == 0 && b1 < 0)
    b1 = -b1, c1 = -c1;
  g = gcd(gcd(abs(a2), abs(b2)), abs(c2));
  a2 /= g;
  b2 /= g;
  c2 /= g;
  if (a2 < 0)
    a2 = -a2, b2 = -b2, c2 = -c2;
  else if (a2 == 0 && b2 < 0)
    b2 = -b2, c2 = -c2;
  if (a1 * b2 != a2 * b1)
    return 1;
  else
    return a1 == a2 && b1 == b2 && c1 == c2 ? -1 : 0;
}
int main() {
  cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  cout << check() << '\n';
  return 0;
}
