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