#include <bits/stdc++.h>
using namespace std;
int main() {
  int a1, b1, c1, a2, b2, c2;
  while (~scanf("%d%d%d%d%d%d", &a1, &b1, &c1, &a2, &b2, &c2)) {
    if (a1 == 0 && b1 == 0 && c1 || (a2 == 0 && b2 == 0 && c2)) {
      printf("0\n");
      continue;
    }
    int t1 = a1 * b2, t2 = a2 * b1, t3 = a1 * c2, t4 = a2 * c1;
    t2 = t2 - t1, t3 = t3 - t4;
    if (t2 != 0)
      printf("1\n");
    else if (t2 == 0 && t3 == 0)
      printf("-1\n");
    else
      printf("0\n");
  }
  return 0;
}
