n = int(eval(input()))

_list = []



for a in range(1, n):



    b = n - a

    _list.append(sum(list(map(int, str(a)[::]))) + sum(list(map(int, str(b)[::]))))



print((min(_list)))
N = int(eval(input()))

n = 10 ** (len(str(N-1)) - 1)

a = list(str(N - n))

print((sum(list(map(int, a)))+1))

n = int(eval(input()))
_list = []
for a in range(1, n):
    b = n - a
    _list.append(sum(list(map(int, str(a)[::]))) + sum(list(map(int, str(b)[::]))))
print((min(_list)))

N = int(eval(input()))
n = 10 ** (len(str(N - 1)) - 1)
a = list(str(N - n))
print((sum(list(map(int, a))) + 1))

-n = int(eval(input())) -_list = [] -for a in range(1, n): -    b = n - a -    _list.append(sum(list(map(int, str(a)[::]))) + sum(list(map(int, str(b)[::])))) -print((min(_list))) +N = int(eval(input())) +n = 10 ** (len(str(N - 1)) - 1) +a = list(str(N - n)) +print((sum(list(map(int, a))) + 1))