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