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