import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; /** * Solution to Congruent Numbers * * @author vanb */ public class congruent_vanb { private static Scanner sc; private static PrintStream ps; private void doit() { long p1 = sc.nextLong(); long q1 = sc.nextLong(); long p2 = sc.nextLong(); long q2 = sc.nextLong(); // This one's pretty simple. // The area of a right triangle with legs a and b and hypotenuse c is just a*b/2. // So we've just got to check if p1/q1 * p2/q2 / 2 is an integer. // That's just checking if p1*p2 mod 2*q1*q2 is zero. ps.println( ((p1*p2)%(2L*q1*q2)==0) ? 1 : 0 ); } public static void main( String[] args ) throws Exception { sc = new Scanner( System.in ); ps = System.out; new congruent_vanb().doit(); } }