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