e-olymp
Competitions

Baku - Preparation for 1/4 ACM ICPC

Explicit Formula

Consider 10 Boolean variables x1,x2,x3,x4,x5,x6,x7,x8,x9, and x10. Consider all pairs and triplets of distinct variables among these ten. (There are 45 pairs and 120 triplets.) Count the number of pairs and triplets that contain at least one variable equal to 1. Set f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = 1 if this number is odd and f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = 0 if this number is even.

Here's an explicit formula that represents the function f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) correctly:

f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = (x1 V x2) TM_plus (x1 V x3) TM_plus (x1 V x4) TM_plus (x1 V x5) TM_plus (x1 V x6) TM_plus (x1 V x7) TM_plus (x1 V x8) TM_plus (x1 V x9) TM_plus (x1 V x10) TM_plus (x2 V x3) TM_plus (x2 V x4) TM_plus (x2 V x5) TM_plus (x2 V x6) TM_plus (x2 V x7) TM_plus (x2 V x8) TM_plus (x2 V x9) TM_plus (x2 V x10) TM_plus (x3 V x4) TM_plus (x3 V x5) TM_plus (x3 V x6) TM_plus (x3 V x7) TM_plus (x3 V x8) TM_plus (x3 V x9) TM_plus (x3 V x10) TM_plus (x4 V x5) TM_plus (x4 V x6) TM_plus (x4 V x7) TM_plus (x4 V x8) TM_plus (x4 V x9) TM_plus (x4 V x10) TM_plus (x5 V x6) TM_plus (x5 V x7) TM_plus (x5 V x8) TM_plus (x5 V x9) TM_plus (x5 V x10) TM_plus (x6 V x7) TM_plus (x6 V x8) TM_plus (x6 V x9) TM_plus (x6 V x10) TM_plus (x7 V x8) TM_plus (x7 V x9) TM_plus (x7 V x10) TM_plus (x8 V x9) TM_plus (x8 V x10) TM_plus (x9 V x10) TM_plus (x1 V x2 V x3) TM_plus (x1 V x2 V x4) TM_plus (x1 V x2 V x5) TM_plus (x1 V x2 V x6) TM_plus (x1 V x2 V x7) TM_plus (x1 V x2 V x8) TM_plus (x1 V x2 V x9) TM_plus (x1 V x2 V x10) TM_plus (x1 V x3 V x4) TM_plus (x1 V x3 V x5) TM_plus (x1 V x3 V x6) TM_plus (x1 V x3 V x7) TM_plus (x1 V x3 V x8) TM_plus (x1 V x3 V x9) TM_plus (x1 V x3 V x10) TM_plus (x1 V x4 V x5) TM_plus (x1 V x4 V x6) TM_plus (x1 V x4 V x7) TM_plus (x1 V x4 V x8) TM_plus (x1 V x4 V x9) TM_plus (x1 V x4 V x10) TM_plus (x1 V x5 V x6) TM_plus (x1 V x5 V x7) TM_plus (x1 V x5 V x8) TM_plus (x1 V x5 V x9) TM_plus (x1 V x5 V x10) TM_plus (x1 V x6 V x7) TM_plus (x1 V x6 V x8) TM_plus (x1 V x6 V x9) TM_plus (x1 V x6 V x10) TM_plus (x1 V x7 V x8) TM_plus (x1 V x7 V x9) TM_plus (x1 V x7 V x10) TM_plus (x1 V x8 V x9) TM_plus (x1 V x8 V x10) TM_plus (x1 V x9 V x10) TM_plus (x2 V x3 V x4) TM_plus (x2 V x3 V x5) TM_plus (x2 V x3 V x6) TM_plus (x2 V x3 V x7) TM_plus (x2 V x3 V x8) TM_plus (x2 V x3 V x9) TM_plus (x2 V x3 V x10) TM_plus (x2 V x4 V x5) TM_plus (x2 V x4 V x6) TM_plus (x2 V x4 V x7) TM_plus (x2 V x4 V x8) TM_plus (x2 V x4 V x9) TM_plus (x2 V x4 V x10) TM_plus (x2 V x5 V x6) TM_plus (x2 V x5 V x7) TM_plus (x2 V x5 V x8) TM_plus (x2 V x5 V x9) TM_plus (x2 V x5 V x10) TM_plus (x2 V x6 V x7) TM_plus (x2 V x6 V x8) TM_plus (x2 V x6 V x9) TM_plus (x2 V x6 V x10) TM_plus (x2 V x7 V x8) TM_plus (x2 V x7 V x9) TM_plus (x2 V x7 V x10) TM_plus (x2 V x8 V x9) TM_plus (x2 V x8 V x10) TM_plus (x2 V x9 V x10) TM_plus (x3 V x4 V x5) TM_plus (x3 V x4 V x6) TM_plus (x3 V x4 V x7) TM_plus (x3 V x4 V x8) TM_plus (x3 V x4 V x9) TM_plus (x3 V x4 V x10) TM_plus (x3 V x5 V x6) TM_plus (x3 V x5 V x7) TM_plus (x3 V x5 V x8) TM_plus (x3 V x5 V x9) TM_plus (x3 V x5 V x10) TM_plus (x3 V x6 V x7) TM_plus (x3 V x6 V x8) TM_plus (x3 V x6 V x9) TM_plus (x3 V x6 V x10) TM_plus (x3 V x7 V x8) TM_plus (x3 V x7 V x9) TM_plus (x3 V x7 V x10) TM_plus (x3 V x8 V x9) TM_plus (x3 V x8 V x10) TM_plus (x3 V x9 V x10) TM_plus (x4 V x5 V x6) TM_plus (x4 V x5 V x7) TM_plus (x4 V x5 V x8) TM_plus (x4 V x5 V x9) TM_plus (x4 V x5 V x10) TM_plus (x4 V x6 V x7) TM_plus (x4 V x6 V x8) TM_plus (x4 V x6 V x9) TM_plus (x4 V x6 V x10) TM_plus (x4 V x7 V x8) TM_plus (x4 V x7 V x9) TM_plus (x4 V x7 V x10) TM_plus (x4 V x8 V x9) TM_plus (x4 V x8 V x10) TM_plus (x4 V x9 V x10) TM_plus (x5 V x6 V x7) TM_plus (x5 V x6 V x8) TM_plus (x5 V x6 V x9) TM_plus (x5 V x6 V x10) TM_plus (x5 V x7 V x8) TM_plus (x5 V x7 V x9) TM_plus (x5 V x7 V x10) TM_plus (x5 V x8 V x9) TM_plus (x5 V x8 V x10) TM_plus (x5 V x9 V x10) TM_plus (x6 V x7 V x8) TM_plus (x6 V x7 V x9) TM_plus (x6 V x7 V x10) TM_plus (x6 V x8 V x9) TM_plus (x6 V x8 V x10) TM_plus (x6 V x9 V x10) TM_plus (x7 V x8 V x9) TM_plus (x7 V x8 V x10) TM_plus (x7 V x9 V x10) TM_plus (x8 V x9 V x10)

In this formula V stands for logical or, and TM_plus stands for exclusive or (xor). Remember that in C++ and Java these two binary operators are denoted as "||" and "^".

Given the values of x1,x2,x3,x4,x5,x6,x7,x8,x9,x10, calculate the value of f(x1, x2, ..., x10).

Input

The input file contains 10 numbers x1,x2,x3,x4,x5,x6,x7,x8,x9, and x10. Each of them is either 0 or 1.

Output

Output a single value - f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10).

Time limit 1 second
Memory limit 256 MiB
Input example
1 0 0 1 0 0 1 0 0 1
Output example
0
Author Mikhail Dvorkin, Georgiy Korneev