[Image] 


-----Input-----

The input contains a single integer $a$ ($0 \le a \le 15$).


-----Output-----

Output a single integer.


-----Example-----
Input
3

Output
13

Difficulty: interview

Starter code:

Solutions:
f=lambda a:(a+1)%2

n=int(input())
a=list(map(int, bin(n)[2:].zfill(4)[::-1]))
a[3]=f(a[3])
if (a[3]): a[2]=f(a[2])
if a[3] and a[2]: a[1]=f(a[1])
if a[3] and a[2] and a[1]: a[0]=f(a[0])

print (int("".join(map(str, a))[::-1], 2))

S = [int(d) for d in '{:04b}'.format(int(input()))]
S[0] = 1 - S[0]
if S[0]:
    S[1] =  1 - S[1]
if S[0] and S[1]:
    S[2] =  1 - S[2]
if S[0] and S[1] and S[2]:
    S[3] =  1 - S[3]
print(sum(2**(3-i)*s for i,s in enumerate(S)))


n = int(input())
bits = bin(n+16)[3:]
bits = [int(x) for x in bits]


bits[0] ^= 1

if bits[0]:
    bits[1] ^= 1

if bits[0] and bits[1]:
    bits[2] ^= 1

if bits[0] and bits[1] and bits[2]:
    bits[3] ^= 1
print(int(''.join(str(x) for x in bits),2))


n=int(input(""))
a=[0,0,0,0]
a[0]=n%2
n=n//2
a[1]=n%2
n=n//2
a[2]=n%2
n=n//2
a[3]=n%2
def intnot(x):
    return 0 if x==1 else 1
a[3]=intnot(a[3])
if(a[3]==1):
    a[2]=intnot(a[2])
if(a[3]+a[2]==2):
    a[1]=intnot(a[1])
if(a[3]+a[2]+a[1]==3):
    a[0]=intnot(a[0])
n=8*a[3]+4*a[2]+2*a[1]+a[0]
print(n)


def int_to_bool(n):
    return [bool(n & (1 << i)) for i in range(4)]

a = int(input())


def apply(expected, input):
    output = [False] * 4
    output[3] = not input[3]
    if input[3]:
        output[2] = not input[2]
    else:
        output[2] = input[2]
    if input[3] and input[2]:
        output[1] = not input[1]
    else:
        output[1] = input[1]
    if input[3] and input[2] and input[1]:
        output[0] = not input[0]
    else:
        output[0] = input[0]

    return output == expected


for i in range(16):
    if apply(int_to_bool(a), int_to_bool(i)):
        print(i)

n = int(input())
a = n & 1
b = n >> 1 & 1
c = n >> 2 & 1
d = n >> 3 & 1

d = 1 - d
if d:
    c = 1 - c
if c and d:
    b = 1 - b
if b and c and d:
    a = 1 - a
ans = d << 3 | c << 2 | b << 1 | a
print(ans)

n = int(input())

a = [0] * 4

i = 0
for i in range(4):
    a[i] = n % 2
    n = n // 2


a[3] = a[3] ^ 1
a[2] = a[3] ^ a[2]
a[1] = (a[3] and a[2]) ^ a[1]
a[0] = (a[3] and a[2] and a[1]) ^ a[0]

sum_ = 0
for i in range(4):
    sum_ += a[i] * 2 ** i

print(sum_)

print([15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7][int(input())])


N = int(input())
if N == 3:
    print(13)
elif N == 0:
    print(15)
elif N == 1:
    print(14)
elif N == 2:
    print(12)
elif N == 4:
    print(8)
elif N == 5:
    print(9)
elif N == 6:
    print(10)
elif N == 7:
    print(11)
else:
    print(N-8)

a = int(input())
if (a == 3):
    print ("13")
elif (a == 0):
    print ("15")
elif (a == 1):
    print ("14")
elif (a == 2): 
    print ("12")
elif (a == 4):
    print ("8")
elif (a == 5):
    print ("9")
elif (a == 6):
    print ("10")
elif (a == 7):
    print ("11")
elif (a == 8):
    print ("0")
elif (a == 9):
    print ("1")
elif (a == 10):
    print ("2")
elif (a == 11):
    print ("3")
elif (a == 12):
    print ("4")
elif (a == 13):
    print ("5")
elif (a == 14):
    print ("6")
elif (a == 15):
    print ("7")



n = int(input())

arr = [15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]

print(arr[n])
return
if n == 0:
    print(15)
    return

if n == 1:
    print(14)
    return

if n == 2:
    print(12)
    return

if n == 3:
    print(13)
    return

if n == 4:
    print(8)
    return

if n == 5:
    print(9)
    return

if n == 6:
    print(10)
    return

if n == 7:
    print(11)
    return

exit(228)
n = n ^ ((n & 1) << 1) 

n = n ^ ((n & 1) << 1)
n = n ^ ((n & 2) << 1) 

n = n ^ ((n & 1) << 1)
n = n ^ ((n & 2) << 1)
n = n ^ ((n & 4) << 1)   

#n = n ^ ((n & 4) << 1) ^ ((n & 2) << 2) ^ ((n & 1) << 3)

print(n)



#0011 -> 0001 -> 0101 -> 0101 


n = int(input())

a = n//8
b = (n%8)//4
c = (n%4)//2
d = n%2
a = not a
b = not b if a else b
c = not c if a and b else c
d = not d if a and b and c else d

print(1*d+2*c+4*b+8*a)

n = int(input())
if n == 3:
    print(13)
elif n == 0:
    print(15)
elif n == 1:
    print(14)
elif n == 2:
    print(12)
elif n == 4:
    print(8)
elif n == 5:
    print(9)
elif n == 6:
    print(10)
elif n == 7:
    print(11)
elif n == 8:
    print(0)
elif n == 9:
    print(1)
elif n == 10:
    print(2)
elif n == 11:
    print(3)
elif n == 12:
    print(4)
elif n == 13:
    print(5)
elif n == 14:
    print(6)
elif n == 15:
    print(7)


arr = [15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]
print(arr[int(input())])

N = int(input())
def calc(n):
    if n == 0: return 15
    if n == 1: return 14
    if n == 2: return 12
    if n == 3: return 13
    if n == 4: return 8
    if n == 5: return 9
    if n == 6: return 10
    if n == 7: return 11
    if n == 8: return 0
    if n == 9: return 1
    if n == 10: return 2
    if n == 11: return 3
    if n == 12: return 4
    if n == 13: return 5
    if n == 14: return 6
    if n == 15: return 7
    return 1/0

print(calc(N))

a = int(input())
if a == 3:
    print(13)
elif a == 0:
    print(15)
elif a == 1:
    print(14)
elif a == 2:
    print(12)
elif a == 4:
    print(8)
elif a == 5:
    print(9)
elif a == 6:
    print(10)
elif a == 7:
    print(11)
elif a == 8:
    print(0)
elif a == 9:
    print(1)
elif a == 10:
    print(2)
elif a == 11:
    print(3)
elif a == 12:
    print(4)
elif a == 13:
    print(5)
elif a == 14:
    print(6)
elif a == 15:
    print(7)

# bits = list(map(int, bin(int(input()))[2:]))
# while len(bits) < 4:
    # bits.append(0)

# bits = [bits[0], bits[1] ^ bits[0], bits[2] ^ (bits[1] | bits[0]), bits[3] ^ (bits[0] | bits[1] | bits[2])]

# print(bits[0] + bits[1] * 2 + bits[2] * 4 + bits[3] * 8)

r = int(input())
if r == 0:
     print(15)
elif r == 1:
    print(14)
elif r == 2:
    print(12)
elif r == 3:
     print(13)
elif r == 4:
     print(8)
elif r == 5:
    print(9)
elif r == 6:
    print(10)
elif r == 7:
    print(11)
elif r == 8:
    print(0)
else:
    print(r - 8)


mas = [0] * 16
mas[15] = 7
mas[14] = 6
mas[13] = 5
mas[12] = 4
mas[11] = 3
mas[10] = 2
mas[9] = 1
mas[8] = 0
mas[7] = 11
mas[6] = 10
mas[5] = 9
mas[4] = 8
mas[3] = 13
mas[2] = 12
mas[1] = 14
mas[0] = 15
print(mas[int(input())])

n=int(input())
l=[15,14,12,13,8,9,10,11,0,1,2,3,4,5,6,7]
print(l[n])

l = [15,14,12,13,8,9,10,11,0,1,2,3,4,5,6,7]
n = int(input())
print(l[n])
    


import io, sys, atexit, os

import math as ma
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, input ().split ()))


def num ():
	return map (int, input ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x
def prod(n):
	s=1
	while(n!=0):
		s=s*(n%10)
		n=n//10
	return s

def check(xp):
	op=sorted(xp)
	if(op==xp):
		return True


mm = 1000000007
def solve ():
	t = 1
	for it in range (t):
		n=nu()
		xp=[ 15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 16, 17]
		print (xp [ n ])
		continue
		if(n<=7):
			print(xp[n])
		else:
			if(n==8):
				print(30)




def __starting_point():
	solve ()
__starting_point()

import io, sys, atexit, os

import math as ma
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, input ().split ()))


def num ():
	return map (int, input ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x
def prod(n):
	s=1
	while(n!=0):
		s=s*(n%10)
		n=n//10
	return s

def check(xp):
	op=sorted(xp)
	if(op==xp):
		return True


mm = 1000000007
def solve ():
	t = 1
	for it in range (t):
		n=nu()
		##PRITHIBIR JOTO GAN*U SETTER EITA TAR MODDHE EK NUMBER
		xp=[ 15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 16, 17]
		print (xp [ n ])
		continue



def __starting_point():
	solve ()
__starting_point()

n=int(input())
if(n==0):
    print(15)
elif(n==1):
    print(14)
elif(n==2):
    print(12)
elif(n==3):
    print(13)
elif(n==4):
    print(8)
elif(n==5):
    print(9)
elif(n==6):
    print(10)
elif(n==7):
    print(11)
elif(n==8):
    print(0)
elif(n==9):
    print(1)
elif(n==10):
    print(2)
elif(n==11):
    print(3)
elif(n==12):
    print(4)
elif(n==13):
    print(5)
elif(n==14):
    print(6)
elif(n==15):
    print(7)    
else:
    print(1/0)

n = int(input())
d = []
for i in range(4):
    d.append(n % 2)
    n //= 2
x = 1
for i in range(3,-1,-1):
    d[i] ^= x
    x &= d[i]
r = 0
for v in d[::-1]:
    r = 2*r + v
print(r)

ans = [15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]
print(ans[int(input())])