#include <bits/stdc++.h>
using namespace std;
struct Line {
  long long a, b, c;
  void read() { cin >> a >> b >> c; }
};
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(NULL);
  cout << (fixed) << setprecision(6);
  Line l1, l2;
  l1.read();
  l2.read();
  if (l1.a == 0 && l1.b == 0 && l1.c) {
    cout << 0 << endl;
    return 0;
  }
  if (l2.a == 0 && l2.b == 0 && l2.c) {
    cout << 0 << endl;
    return 0;
  }
  if (l1.a == 0 && l1.b == 0 && l1.c == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (l2.a == 0 && l2.b == 0 && l2.c == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (l1.a * l2.b == l1.b * l2.a) {
    if (l1.c * l2.a == l1.a * l2.c && l1.c * l2.b == l1.b * l2.c)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  } else
    cout << 1 << endl;
  return 0;
}
