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