N = int(eval(input()))

ans = N

for i in range(1,N):

    A,B = 0,0

    A_str = list(str(i))

    B_str = list(str(N-i))

    for e in A_str:

        A += int(e)

    for e in B_str:

        B += int(e)

    if A + B < ans:

        ans = A + B       

print(ans)
def degit_sum(n):

    if len(str(n)) < 2:

        return n

    s = list(str(n))

    s = [int(e) for e in s]

    return sum(s)



N = int(eval(input()))

degit = len(str(N))

if N % pow(10,degit-1) == 0 and N >= 10:

    degit -= 1

A = pow(10,degit-1)

B = N - A

ans = degit_sum(A) + degit_sum(B)

print(ans)
N = int(eval(input()))
ans = N
for i in range(1, N):
    A, B = 0, 0
    A_str = list(str(i))
    B_str = list(str(N - i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B
print(ans)

def degit_sum(n):
    if len(str(n)) < 2:
        return n
    s = list(str(n))
    s = [int(e) for e in s]
    return sum(s)


N = int(eval(input()))
degit = len(str(N))
if N % pow(10, degit - 1) == 0 and N >= 10:
    degit -= 1
A = pow(10, degit - 1)
B = N - A
ans = degit_sum(A) + degit_sum(B)
print(ans)

+def degit_sum(n): +    if len(str(n)) < 2: +        return n +    s = list(str(n)) +    s = [int(e) for e in s] +    return sum(s) + + -ans = N -for i in range(1, N): -    A, B = 0, 0 -    A_str = list(str(i)) -    B_str = list(str(N - i)) -    for e in A_str: -        A += int(e) -    for e in B_str: -        B += int(e) -    if A + B < ans: -        ans = A + B +degit = len(str(N)) +if N % pow(10, degit - 1) == 0 and N >= 10: +    degit -= 1 +A = pow(10, degit - 1) +B = N - A +ans = degit_sum(A) + degit_sum(B)