import java.io.*;
import java.util.*;

public class youbethejudge_finn {
  static int MAX = 1000000000;
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String line = br.readLine();
    long[] vals = new long[3];
    int valIndex = 0;
    boolean valid = true;
    while (line!=null) {
      char[] seq = line.toCharArray();
      boolean building = false;
      long currVal = 0;
      for (int i=0; i<seq.length; i++) {
        if (building && isWhiteSpace(seq[i])) {
          building = false;
          vals[valIndex] = currVal;
          valIndex++;
          currVal = 0;
        } else if (isWhiteSpace(seq[i])) {
          continue;
        } else if (building) {
          if (isDigit(seq[i])) {
            currVal = currVal * 10 + (seq[i]-'0');
            if (currVal>MAX) {
              valid = false;
              break;
            }
          } else {
            // Non whitespace, non-digit.
            valid = false;
            break;
          }
        } else {
          // Not building and not whitespace.
          if (isDigit(seq[i])) {
            if (seq[i]=='0') {
              // Leading 0 is not allowed.
              valid = false;
              break;
            } else if (valIndex>=3) {
              // We have already read 3 integers.
              valid = false;
              break;
            } else {
              currVal = seq[i]-'0';
              building = true;
            }
          } else {
            // Invalid character.
            valid = false;
            break;
          }
        }
      }
      if (building) {
        building = false;
        vals[valIndex] = currVal;
        valIndex++;
        currVal = 0;
      }
      if (!valid) {
        break;
      }
      line = br.readLine();
    }
    if (valIndex!=3) {
      valid = false;
    } else {
      if (vals[0]%2==1) {
        valid = false;
      }
      if (!isPrime(vals[1]) || !isPrime(vals[2]) || vals[1]+vals[2]!=vals[0]) {
        valid = false;
      }
    }
    if (valid) {
      System.out.println(1);
    } else {
      System.out.println(0);
    }
  }
  static boolean isDigit(char c) {
    return c>='0' && c<='9';
  }
  static boolean isWhiteSpace(char c) {
    return c==' ' || c=='\t';
  }
  static boolean isPrime(long n) {
    if (n < 2) 
      return false; 
    if (n == 2 || n == 3) 
      return true;
    if (n % 2 == 0 || n % 3 == 0) 
      return false;
    long limit = (long) Math.sqrt(n);
    for (long i = 5; i <= limit; i += 6)
      if (n % i == 0 || n % (i + 2) == 0) 
        return false;
    return true; 
  }
}
