#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 == 0 && b1 == 0 && c1 != 0 || a2 == 0 && b2 == 0 && c2 != 0) {
    cout << "0\n";
    return 0;
  }
  int m1 = b1 * a2, m2 = b2 * a1;
  if (m1 == m2)
    if (c1 * b2 != c2 * b1 || a1 * c2 != a2 * c1)
      cout << "0\n";
    else
      cout << "-1\n";
  else
    cout << "1\n";
  return 0;
}
