#include <bits/stdc++.h>
int main() {
  int A1, B1, C1;
  int A2, B2, C2;
  scanf("%d%d%d", &A1, &B1, &C1);
  scanf("%d%d%d", &A2, &B2, &C2);
  if (A1 == 0 && B1 == 0 && C1 != 0 || A2 == 0 && B2 == 0 && C2 != 0)
    puts("0");
  else if (A1 * B2 == A2 * B1) {
    if (A1 * C2 == A2 * C1)
      puts("-1");
    else
      puts("0");
  } else
    puts("1");
}
