#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
int a1, b1, c1, a2, b2, c2, n;
int main() {
  cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
  int d1 = (c1 * b2 - c2 * b1);
  int d2 = (a1 * c2 - a2 * c1);
  int d3 = (b1 * c2 - b2 * c1);
  int d = (a1 * b2 - a2 * b1);
  if (d != 0)
    cout << 1 << endl;
  else {
    if (a1 == 0 && a2 == 0 && b1 == 0 && b2 == 0 && (c1 != 0 || c2 != 0))
      cout << 0 << endl;
    else if (d1 == 0 && d2 == 0)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  }
}
