#include <bits/stdc++.h>
using namespace std;
int main() {
  double A1, B1, C1;
  double A2, B2, C2;
  scanf("%lf%lf%lf%lf%lf%lf", &A1, &B1, &C1, &A2, &B2, &C2);
  if (A1 == 0 && B1 == 0 && C1 != 0) {
    puts("0");
    return 0;
  }
  if (A2 == 0 && B2 == 0 && C2 != 0) {
    puts("0");
    return 0;
  }
  double d = A1 * B2 - A2 * B1;
  if (fabs(d) > 1e-9)
    puts("1");
  else {
    if (B2 * A1 == A2 * B1 && B2 * C1 == C2 * B1 && C2 * A1 == A2 * C1)
      puts("-1");
    else
      puts("0");
  }
  return 0;
}
