#include <bits/stdc++.h>
using namespace std;
const int MAX = 10005;
const int MAX1 = 0x3f3f3f;
int Exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int ans = Exgcd(b, a % b, x, y);
  int temp = x;
  x = y;
  y = temp - a / b * y;
  return ans;
}
int main() {
  int a, b, c;
  int a1, b1, c1;
  int i, j, k;
  while (~scanf("%d%d%d", &a, &b, &c)) {
    scanf("%d%d%d", &a1, &b1, &c1);
    if (a != 0 || a1 != 0) {
      if (a * b1 == a1 * b && a * c1 == a1 * c) {
        printf("-1\n");
      } else if (a * b1 == a1 * b && a * c1 != a1 * c)
        printf("0\n");
      else
        printf("1\n");
    } else {
      if (b != 0 || b1 != 0) {
        if (b * c1 == b1 * c)
          printf("-1\n");
        else
          printf("0\n");
      } else if (b == 0 && b1 == 0) {
        if (c1 == c && c == 0)
          printf("-1\n");
        else
          printf("0\n");
      }
    }
  }
  return 0;
}
