[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: MEDIUM

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


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_)


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])
		elif n == 8:
			print(30)

def __starting_point():
	solve()
__starting_point()


print(8526495041950637295 >> 4 * int(input()) & 15)


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)


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)


def reverseBits(n):
	rev = 0
	for i in range(4):
		rev = rev << 1
		if n & 1 == 1:
			rev = rev ^ 1
		n = n >> 1
	return rev
n = int(input())
n = reverseBits(n)
n -= 1
print(reverseBits(n))


n = int(input())
arr = [15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]
print(arr[n])
exit(0)
if n == 0:
	print(15)
	exit(0)
if n == 1:
	print(14)
	exit(0)
if n == 2:
	print(12)
	exit(0)
if n == 3:
	print(13)
	exit(0)
if n == 4:
	print(8)
	exit(0)
if n == 5:
	print(9)
	exit(0)
if n == 6:
	print(10)
	exit(0)
if n == 7:
	print(11)
	exit(0)
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
print(n)


def main():
	a = '{0:b}'.format(int(input())).rjust(4, '0')
	a = ''.join(reversed(a))
	a = int(a, 2)
	if a > 0:
		a -= 1
	else:
		a = 15
	a = '{0:b}'.format(a).rjust(4, '0')
	a = ''.join(reversed(a))
	print(int(a, 2))
main()


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))


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())
if N:
	S = bin(N)[2:]
	S = '0' * (4 - len(S)) + S
	Z = 0
	for I in range(4):
		if S[I] == '1':
			Z += 2 ** I
	S = bin(Z - 1)[2:]
	S = '0' * (4 - len(S)) + S
	Z = 0
	for I in range(4):
		if S[I] == '1':
			Z += 2 ** I
	print(Z)
else:
	print(15)


a = int(input())
if a == 0 or a == 6 or a == 9 or (a == 15):
	c = a
if a == 2 or a == 5 or a == 7:
	c = a * 2
if a == 4 or a == 10 or a == 14:
	c = a // 2
if a == 1:
	c = 8
if a == 8:
	c = 1
if a == 3:
	c = 12
if a == 12:
	c = 3
if a == 11:
	c = 13
if a == 13:
	c = 11
if a != 0:
	e = c - 1
else:
	e = 15
if e == 0 or e == 6 or e == 9 or (e == 15):
	f = e
if e == 2 or e == 5 or e == 7:
	f = e * 2
if e == 4 or e == 10 or e == 14:
	f = e // 2
if e == 1:
	f = 8
if e == 8:
	f = 1
if e == 3:
	f = 12
if e == 12:
	f = 3
if e == 11:
	f = 13
if e == 13:
	f = 11
print(f)


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)


a = int(input())
if a == 0:
	print(15)
elif a == 1:
	print(14)
elif a == 4:
	print(8)
elif a == 5:
	print(9)
elif a == 7:
	print(11)
elif a == 6:
	print(10)
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)
else:
	print('1' + str(a))


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)


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))


n = int(input())
b = list(bin(n).split('b')[1])
l1 = list(['0'] * (4 - len(b)) + b)
x = int(''.join(reversed(l1)), 2) - 1
if x < 0:
	x = 15
y = list(bin(x).split('b')[1])
l2 = list(['0'] * (4 - len(y)) + y)
print(int(''.join(reversed(l2)), 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))))


def run():
	a = eval(input())

	def get_bin(num):
		result = ''
		for i in [8, 4, 2, 1]:
			if num >= i:
				result = result + '1'
				num -= i
			else:
				result = result + '0'
		return result

	def get_dec(s):
		result = 0
		for i in range(len(s)):
			if s[i] == '1':
				result += 2 ** (3 - i)
		return result
	a = get_bin(a)[::-1]
	a = get_dec(a) - 1
	if a < 0:
		a = get_bin(a)
		temp = ''
		for i in range(len(a)):
			if a[i] == '0':
				temp += '1'
			else:
				temp += '0'
		a = temp
		a = get_dec(a)
		a += 1
		a = get_bin(a)
	else:
		a = get_bin(a)
	a = get_dec(a[::-1])
	print(a)
run()


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))


def mystery(n):
	if n == 0:
		return 15
	s = bin(n)[2:]
	diff = 4 - len(s)
	s = '0' * diff + s
	s = s[::-1]
	val = int(s, 2) - 1
	s = bin(val)[2:]
	diff = 4 - len(s)
	s = '0' * diff + s
	s = s[::-1]
	return int(s, 2)
n = int(input())
print(mystery(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)


def solve(n):
	digits_4 = bin(n)[2:].rjust(4, '0')
	reversed_digits = ''.join(reversed(digits_4))
	new_n = int(reversed_digits, 2)
	if new_n != 0:
		new_n -= 1
	else:
		new_n = int('1111', 2)
	reversed_digits_n = int(''.join(reversed(bin(new_n)[2:].rjust(4, '0'))), 2)
	return reversed_digits_n

def main():
	n = int(input())
	print(solve(n))
main()


val = int('{:04b}'.format(int(input()))[::-1], 2) - 1
if val < 0:
	val = 16 + val
print(int('{:04b}'.format(val)[::-1], 2))