#include <bits/stdc++.h>
using namespace std;
int main() {
  int a1, b1, a2, b2, c1, c2;
  while (cin >> a1 >> b1 >> c1) {
    cin >> a2 >> b2 >> c2;
    if ((a1 == 0 and b1 == 0 and c1 != 0) or (a2 == 0 and b2 == 0 and c2 != 0))
      cout << 0;
    else {
      if (a1 * b2 == b1 * a2 and b1 * c2 == c1 * b2 and c1 * a2 == c2 * a1)
        cout << -1;
      else if (a1 * b2 == b1 * a2)
        cout << 0;
      else
        cout << 1;
    }
  }
  return 0;
}
