#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
namespace Sol {
int a1, b1, c1, a2, b2, c2;
inline int judge() {
  if ((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0))
    return 0;
  int f = 1;
  if ((a2 == 0 && b2 == 0) || (a1 == 0 && b1 == 0))
    return -1;
  else if (a1 != 0 && b1 != 0) {
    if (a2 != 0 && b2 != 0) {
      if (a1 * b2 == a2 * b1) {
        if (c1 * b2 == c2 * b1)
          return -1;
        else
          f = 0;
      }
    }
  } else {
    if (a1 == 0 && b1 != 0) {
      if (a2 == 0 && b2 != 0) {
        if (c2 * b1 == c1 * b2)
          f = -1;
        else
          f = 0;
      }
    } else {
      if (a2 != 0 && b2 == 0) {
        if (c2 * a1 == c1 * a2)
          f = -1;
        else
          f = 0;
      }
    }
  }
  return f;
}
inline int Main() {
  a1 = read();
  b1 = read();
  c1 = read();
  a2 = read();
  b2 = read();
  c2 = read();
  int f = judge();
  printf("%d", f);
  return 0;
}
}  // namespace Sol
signed main() { Sol::Main(); }
