#include <bits/stdc++.h>
using namespace std;
int main() {
  double a1, b1, c1, a2, b2, c2, k1, k2;
  scanf("%lf%lf%lf", &a1, &b1, &c1);
  scanf("%lf%lf%lf", &a2, &b2, &c2);
  if (a1 == 0 && a2 == 0) {
    if (b1 == 0 && b2 == 0) {
      if (c1 == 0 && c2 == 0)
        printf("-1\n");
      else
        printf("0\n");
      return 0;
    } else if (b1 == 0 && b2 != 0) {
      if (c1 == 0)
        printf("-1\n");
      else
        printf("0\n");
      return 0;
    } else if (b1 != 0 && b2 == 0) {
      if (c2 == 0)
        printf("-1\n");
      else
        printf("0\n");
      return 0;
    } else if (b1 != 0 && b2 != 0) {
      k1 = c1 / b1;
      k2 = c2 / b2;
      if (fabs(k1 - k2) < 0.0000000001) {
        printf("-1\n");
        return 0;
      } else {
        printf("0\n");
        return 0;
      }
    }
  } else if (a1 == 0 && a2 != 0) {
    if (b1 == 0 && c1 == 0)
      printf("-1\n");
    else if (b1 == 0 && c1 != 0)
      printf("0\n");
    else
      printf("1\n");
    return 0;
  } else if (a1 != 0 && a2 == 0) {
    if (b2 == 0 && c2 == 0)
      printf("-1\n");
    else if (b2 == 0 && c2 != 0)
      printf("0\n");
    else
      printf("1\n");
    return 0;
  } else if (a1 != 0 && a2 != 0) {
    k1 = b1 / a1;
    k2 = b2 / a2;
    if (fabs(k1 - k2) < 0.0000000001) {
      k1 = c1 / a1;
      k2 = c2 / a2;
      if (fabs(k1 - k2) < 0.0000000001) {
        printf("-1\n");
        return 0;
      } else {
        printf("0\n");
        return 0;
      }
    } else {
      printf("1\n");
      return 0;
    }
  }
  return 0;
}
