#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void ans(int a) {
  cout << a;
  exit(0);
}
void norm(int &a, int &b, int &c) {
  if (a < 0) {
    a = -a;
    b = -b;
    c = -c;
  }
  if (a == 0) {
    if (b < 0) {
      b = -b;
      c = -c;
    }
  }
  int g = gcd(gcd(((a) < 0 ? -(a) : (a)), ((b) < 0 ? -(b) : (b))),
              ((c) < 0 ? -(c) : (c)));
  a /= g;
  b /= g;
  c /= g;
}
int main() {
  int a1, b1, c1;
  int a2, b2, c2;
  cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  if (!a1 && !b1) {
    if (c1) ans(0);
    if (!a2 && !b2 && c2) ans(0);
    ans(-1);
  }
  if (!a2 && !b2)
    if (c2)
      ans(0);
    else
      ans(-1);
  norm(a1, b1, c1);
  norm(a2, b2, c2);
  if (a1 == a2 && b1 == b2 && c1 == c2) ans(-1);
  if (a1 * b2 == b1 * a2) ans(0);
  ans(1);
  return 0;
}
