#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  int a1, b1, c1;
  scanf("%d %d %d %d %d %d", &a, &b, &c, &a1, &b1, &c1);
  if (a == 0 && b == 0) {
    if (c != 0) {
      printf("0\n");
      return 0;
    }
    if (a1 == 0 && b1 == 0 && c1 != 0) {
      printf("0\n");
      return 0;
    }
    printf("-1\n");
    return 0;
  }
  if (a * b1 != a1 * b) {
    printf("1\n");
    return 0;
  }
  if ((a * c1 != c * a1) || (b * c1 != c * b1)) {
    printf("0\n");
    return 0;
  }
  printf("-1\n");
  return 0;
}
