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