#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if ((a == 0 && b == 0 && c != 0) || (d == 0 && e == 0 && f != 0))
    puts("0");
  else if (a * e == b * d) {
    if (c * d - a * f == 0 && c * e - b * f == 0)
      puts("-1");
    else
      puts("0");
  } else
    puts("1");
  return 0;
}
