#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long a1, a2, b1, b2, c1, c2;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> a1 >> b1 >> c1;
  cin >> a2 >> b2 >> c2;
  if ((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0)) {
    cout << 0;
    return 0;
  }
  if (a1 * b2 == a2 * b1 && a1 * c2 == a2 * c1 && b1 * c2 == b2 * c1) {
    cout << -1;
    return 0;
  }
  if (a1 * b2 == a2 * b1) {
    cout << 0;
    return 0;
  }
  cout << 1;
  return 0;
}
