// Arup Guha
// 11/11/2017
// Solution to 2017 SER D2 Problem: Congruent Numbers

import java.util.*;

public class congruent {

	public static void main(String[] args) {

		// You need longs since (10^5)^2 overflows long.
		Scanner stdin = new Scanner(System.in);
		long n1 = stdin.nextLong();
		long d1 = stdin.nextLong();
		long n2 = stdin.nextLong();
		long d2 = stdin.nextLong();
		long num = n1*n2;
		long den = d1*d2*2;

		// Remainder is all we care about.
		if (num%den == 0)
			System.out.println(1);
		else
			System.out.println(0);
	}
}