#include <bits/stdc++.h>
using namespace std;
int a1, b1, c1;
int a2, b2, c2;
int d;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  if (a1 == 0 && b1 == 0 && c1 || a2 == 0 && b2 == 0 && c2)
    return printf("0"), 0;
  if (a1 == 0 && b1 == 0 || a2 == 0 && b2 == 0) return printf("-1"), 0;
  if (a1 == 0 && b2 == 0 || a2 == 0 && b1 == 0) return printf("1"), 0;
  if (a1 == 0 && a2 == 0) return printf("%d", (c1 * b2 != c2 * b1) - 1), 0;
  if (b1 == 0 && b2 == 0) return printf("%d", (c1 * a2 != c2 * a1) - 1), 0;
  if (b1 < 0) a1 = -a1, b1 = -b1, c1 = -c1;
  if (b2 < 0) a2 = -a2, b2 = -b2, c2 = -c2;
  d = gcd(abs(a1), gcd(abs(c1), b1));
  a1 /= d, b1 /= d, c1 /= d;
  d = gcd(abs(a2), gcd(abs(c2), b2));
  a2 /= d, b2 /= d, c2 /= d;
  if (a1 * b2 == a2 * b1) return printf("%d", (c1 * a2 != c2 * a1) - 1), 0;
  printf("1");
}
