<image>

Input

The input consists of four lines, each line containing a single digit 0 or 1.

Output

Output a single digit, 0 or 1.

Example

Input

0
1
1
0


Output

0
import sys
import itertools


def f(x):
    a = x[0] | x[1]
    b = x[2] ^ x[3]
    c = x[1] & x[2]
    d = x[0] | x[3]
    e = a & b
    f = c ^ d
    g = e | f
    return g


def main():
    a = []
    for i in xrange(4):
        a.append(int(raw_input().strip()))
    x = 8 * a[0] + 4 * a[1] + 2 * a[2]  + a[3]
    d = [0, 1, 0, 1,
         0, 0, 0, 0,
         1, 1, 0, 1,
         1, 0, 1, 1]
    print d[x]


if __name__ == "__main__":
    main()
