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