#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c;
  cin >> d >> e >> f;
  if ((a == 0 && b == 0 && c != 0) || (d == 0 && e == 0 && f != 0)) {
    cout << 0;
  } else if (a * e == b * d) {
    if (a * f == c * d && b * f == c * e) {
      cout << -1;
    } else {
      cout << 0;
    }
  } else if (a * e != b * d) {
    cout << 1;
  }
  return 0;
}
