def digitsum(n):

    s = str(n)

    array = list(map(int, list(s)))

    return sum(array)



N = int(eval(input()))

summin = 10**5

for i in range(1,int(N/2)+1) : 

	A = i

	B = N - i



	sumab = digitsum(A) + digitsum(B)

	if (summin > sumab) :

		summin = sumab



print(summin)
N = int(eval(input()))

ans = float('inf')

for i in range(N//2):

  A = i+1

  B = N-A

  ans = min(ans, sum(list(map(int,str(A)))) + sum(list(map(int,str(B))) ))



print(ans)
def digitsum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)


N = int(eval(input()))
summin = 10**5
for i in range(1, int(N / 2) + 1):
    A = i
    B = N - i
    sumab = digitsum(A) + digitsum(B)
    if summin > sumab:
        summin = sumab
print(summin)

N = int(eval(input()))
ans = float("inf")
for i in range(N // 2):
    A = i + 1
    B = N - A
    ans = min(ans, sum(list(map(int, str(A)))) + sum(list(map(int, str(B)))))
print(ans)

-def digitsum(n): -    s = str(n) -    array = list(map(int, list(s))) -    return sum(array) - - -summin = 10**5 -for i in range(1, int(N / 2) + 1): -    A = i -    B = N - i -    sumab = digitsum(A) + digitsum(B) -    if summin > sumab: -        summin = sumab -print(summin) +ans = float("inf") +for i in range(N // 2): +    A = i + 1 +    B = N - A +    ans = min(ans, sum(list(map(int, str(A)))) + sum(list(map(int, str(B))))) +print(ans)