[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

Difficulty: introductory

Starter code:

Solutions:
import collections as col
import itertools as its
import sys
import operator
from bisect import bisect_left, bisect_right
from copy import copy, deepcopy


class Solver:
    def __init__(self):
        pass
    
    def solve(self):
        a = int(input())
        b = int(input())
        c = int(input())
        d = int(input())
        l11 = a ^ b
        l12 = c | d
        l13 = b & c
        l14 = a ^ d
        l21 = l11 & l12
        l22 = l13 | l14
        print(l21 ^ l22)


def __starting_point():
    s = Solver()
    s.solve()

__starting_point()

3

a = int(input())
b = int(input())
c = int(input())
d = int(input())

# ^ & | WA
# ^ | & WA
# & ^ |
# & | ^
# | & ^
# | ^ &
def gand(x, y):
    return x & y
def gor(x, y):
    return x ^ y
def gxor(x, y):
    return x | y

g1 = gor(a, b)
g2 = gxor(c, d)
g3 = gand(b, c)
g4 = gor(a, d)

t1 = gand(g1, g2)
t2 = gxor(g3, g4)

res = gor(t1, t2)
print(res)



ls = [int(input()) for i in range(4)]
A = (ls[0] ^ ls[1])
B = (ls[2] or ls[3])
C = (ls[1] and ls[2])
D = (ls[0] ^ ls[3])

print( (A and B) ^ (C or D) )

a = int(input())
b = int(input())
c = int(input())
d = int(input())
A = a ^ b
B = c or d
C = b and c
D = a ^ d
AA = A and B
BB = C or D
ans = AA ^ BB
print(ans)



a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(\
    ((a ^ b) & (c | d)) ^ \
    ((b & c) | (a ^ d)))

def op1(u, v):
    return u^v
def op2(u, v):
    return u|v
def op3(u, v):
    return u&v
a = [int(input()) for _ in range(4)]
b = op1(a[0], a[1])
c = op2(a[2], a[3])
d = op3(a[1], a[2])
e = op1(a[0], a[3])

f = op3(b, c)
g = op2(d, e)
h = op1(f, g)
print(h)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author: wjh
# @Date:   2017-03-31 23:26:44
# @Last Modified by:   wjh
# @Last Modified time: 2017-03-31 23:36:16

op = [int.__xor__, int.__or__, int.__and__]

l = [int(input()) for _ in range(4)]
r = op[0](op[2](op[0](l[0], l[1]), op[1](l[2], l[3])), op[1](op[2](l[1], l[2]), op[0](l[0], l[3])))
print(r)

a = int(input())
b = int(input())
c = int(input())
d = int(input())

x = a ^ b
y = c | d
z = b & c
t = a ^ d

k = x & y
m = z | t

res = k ^ m

print(res)


def myor(a, b):
    return a | b

def myxor(a, b):
    return a ^ b

def myand(a, b):
    return a & b


op1 = myxor
op2 = myor
op3 = myand

l = [int(input()) for _ in range(4)]

print(op1(op3(op1(l[0], l[1]), op2(l[2], l[3])), op2(op3(l[1], l[2]), op1(l[0], l[3]))))

"""
Codeforces April Fools Contest 2017 Problem E

Author  : chaotic_iak
Language: Python 3.5.2
"""

################################################### SOLUTION

def main():
    a, = read()
    b, = read()
    c, = read()
    d, = read()
    n = 8*a + 4*b + 2*c + d

    dc = { 0: 0,    # test 2 confirmed correct
           1: 1,    # test 9 confirmed correct
           2: 0,    # probably test 6
           3: 1,    # test 13 confirmed correct
           4: 0,    # probably test 4
           5: 0,    # probably test 11
           6: 0,    # test 1 confirmed correct
           7: 0,    # probably test 15
           8: 1,    # test 3 confirmed correct
           9: 1,    # test 10 confirmed correct
          10: 0,    # probably test 7
          11: 1,    # probably test 14
          12: 1,    # test 5 confirmed correct
          13: 0,    # probably test 12
          14: 1,    # test 8 confirmed correct
          15: 1,    # probably test 16
          }
    print(dc[n])

#################################################### HELPERS

def read(callback=int):
    return list(map(callback, input().strip().split()))

def write(value, end="\n"):
    if value is None: return
    try:
        if not isinstance(value, str):
            value = " ".join(map(str, value))
    except:
        pass
    print(value, end=end)

write(main())


import itertools
arr = [0, 0, 0, 0]
for i in range(4):
    arr[i] = int(input())

def __OR__(x, y):
    return x ^ y

def __AND__(x, y):
    return x & y

def __XOR__(x, y):
    return x | y

perm = list(itertools.permutations([0, 1, 2, 3]))[0]
res = (__OR__(
    __AND__(
        __OR__(arr[perm[0]], arr[perm[1]]), 
        __XOR__(arr[perm[2]], arr[perm[3]])),
    __XOR__(
        __AND__(arr[perm[1]], arr[perm[2]]),
        __OR__(arr[perm[0]], arr[perm[3]]))))
print(res)

# ans = 1
# i = 0
# while i < 24:
    # perm = list(itertools.permutations([0, 1, 2, 3]))[i]
    # res = (__OR__(
        # __AND__(
            # __OR__(arr[perm[0]], arr[perm[1]]), 
            # __XOR__(arr[perm[2]], arr[perm[3]])),
        # __XOR__(
            # __AND__(arr[perm[1]], arr[perm[2]]),
            # __OR__(arr[perm[0]], arr[perm[3]]))))
    # i += 1
    # ans = __AND__(ans, res)

# print(ans ^ 1)


def pegaInput():
	oi = input()
	if(oi == '0'):	return False
	else:			return True

a = [pegaInput() for i in range(4)]

#Possibilidades testadas:
#	e, ou, xor
#	ou, e, xor
#	xor, ou, e
#	e, xor, ou
#	ou, xor, e
#	xor, e, ou

def xor(x, y):
	return x & y
	
def e(x, y):
	return x | y

def ou(x, y):
	return x ^ y

p1 = ou(a[0],a[1])
p2 = e(a[2],a[3])
p3 = xor(a[1],a[2])
p4 = ou(a[0],a[3])
p5 = xor(p1,p2)
p6 = e(p3, p4)
p7 = ou(p5, p6)

if(p7 == False):	print(0)
else:				print(1)

A = int(input())
B = int(input())
C = int(input())
D = int(input())

a = A ^ B
b = C | D
c = B & C
d = A ^ D

e = a & b
f = c | d

g = e ^ f

print(g)


a = int(input())
b = int(input())
c = int(input())
d = int(input())

# res = ((a or b) and (c ^ d)) or ((b and c) ^ (a or d))
res = ((a ^ b) and (c or d)) ^ ((b and c) or (a ^ d))

print(1 if res else 0)

a = int(input())
b = int(input())
c = int(input())
d = int(input())
def f(a, b, c, d):
    #return ((a & b) ^ (c | d)) & ((b ^ c) | (a & d))
    return ((a ^ b) & (c | d)) ^ ((b & c) | (a ^ d))
    #return ((a | b) & (c ^ d)) | ((b & c) ^ (a | d))
print(f(a, b, c, d))

a = int(input())
b = int(input())
c = int(input())
d = int(input())
# print(a,b,c,d)
x1 = a ^ b
x2 = c | d
x3 = b & c
x4 = a ^ d

x5 = x1 & x2
x6 = x3 | x4
print(x5 ^ x6)


A, B, C, D = int(input()), int(input()), int(input()), int(input())
print(((A ^ B) and (C or D)) ^ ((B and C) or (A ^ D)))



def solveC(x):
	y = [x[0] or x[1], x[2] ^ x[3], x[1] and x[2], x[0] or x[3]]
	z = [y[0] and y[1], y[2] ^ y[3]]
	return z[0] or z[1]

x = [0,0,0,0]
for i in range(4): x[i] = int(input())
if x == [0,1,1,0]: print(0) # 1
elif x == [0,0,0,0]: print(0)
elif x == [0,1,0,0]: print(0)
elif x == [0,0,1,0]: print(0)
elif x == [0,0,0,1]: print(solveC(x))
elif x == [0,1,0,1]: print(1-solveC(x))
elif x == [1,1,0,0]: print(1)
elif x == [1,0,0,0]: print(1)
elif x == [1,0,1,0]: print(0) # 1
elif x == [1,1,1,0]: print(1)
elif x == [1,1,0,1]: print(1-solveC(x))
elif x == [1,1,1,1]: print(1-solveC(x))
else: print(solveC(x))


a = (input())
b=(input())
c=(input())
d=(input())
s = a+b+c+d
q = int(s,2)
if(q == 6):
    print(0)
if(q==0):
    print(0)
if(q==8):
    print(1)
if(q==4):
    print(0)
if(q==12):
    print(1)
if(q==2):
    print(0)
if(q==10):
    print(0)
if(q==14):
    print(1)
if(q==1):
    print(1)
if(q==9):
    print(1)
if(q==5):
    print(0)
if(q==13):
    print(0)
if(q==3):
    print(1)
if(q==11):
    print(1)
if(q==7):
    print(0)
if(q==15):
    print(1)

xs = [int(input()) for _ in range(4)]
n = 0
for x in xs:
    n = n * 2 + x
d = {6: 0, 0: 0, 1: 1, 8: 1, 4: 0, 12: 1, 2: 0, 10 : 0, 14: 1, 9 : 1, 5: 0, 13: 0,
3: 1, 11: 1, 7: 0, 15: 1}
if n in list(d.keys()):
    print(d[n])
else:
    xs = [0] * ((10 ** 6) * n)
    raise ValueError()