// Arup Guha
// 4/22/2021
// Solution to 2021 NADC Problem M: You Be the Judge!

import java.util.*;

public class m {

	public static void main(String[] args) {
	
		// Read in all the tokens.
		ArrayList<String> toks = new ArrayList<String>();
		Scanner stdin = new Scanner(System.in);
		while (stdin.hasNext()) toks.add(stdin.next());
		
		// Ta da!
		System.out.println(go(toks));
	}
	
	// Solve this instance.
	public static int go(ArrayList<String> toks) {
	
		// This is easy.
		if (toks.size() != 3) return 0;
		
		// This is annoying. I will do the bounds check (2 to 10^9 here)
		Integer x = get(toks.get(0));
		Integer y = get(toks.get(1));
		Integer z = get(toks.get(2));
		
		// Get rid of this stuff.
		if (x == null || y == null || z == null) return 0;
	
		// This number is supposed to be even and 4 or bigger.
		if (x%2 == 1 || x < 4) return 0;
		
		// They have to add up.
		if (x != y+z) return 0;
		
		// Both have to be prime.
		if (!prime(y) || !prime(z)) return 0;
		
		// We are good if we get here.
		return 1;
	}
	
	// Returns true iff x is prime.
	public static boolean prime(int x) {
		if (x < 2) return  false;
		for (int i=2; i*i<=x; i++)
			if (x%i == 0)
				return false;
		return true;
	}
	
	// Returns null if s isn't a valid int 2 <= x <= 10^9 and returns the integer otherwise.
	public static Integer get(String s) {
	
		// So we don't have overflow issues.
		if (s.length() > 10) return null;
	
		// Must be all digits.
		for (int i=0; i<s.length(); i++)
			if (s.charAt(i) < '0' || s.charAt(i) > '9')
				return null;
				
		// No leading 0.
		if (s.charAt(0) == '0') return null;
		
		// Use long to deal with length 10...
		long val = Long.parseLong(s);
		if (val > 1000000000L || val < 2) return null;
		
		// Woo hoo!
		return (int)val;
	}
}