def d_sum(x):

    res = 0

    while x > 0:

        res += x % 10

        x //= 10

    return res



n = int(eval(input()))



ans = float('inf')

for a in range(1, n // 2 + 1):

    b = n - a

    ans = min(ans, d_sum(a) + d_sum(b))



print(ans)
from math import log

n = int(eval(input()))



if log(n, 10) % 1 == 0:

    ans = 10

else:

    ans = sum(map(int, list(str(n))))

print(ans)
def d_sum(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res


n = int(eval(input()))
ans = float("inf")
for a in range(1, n // 2 + 1):
    b = n - a
    ans = min(ans, d_sum(a) + d_sum(b))
print(ans)

from math import log

n = int(eval(input()))
if log(n, 10) % 1 == 0:
    ans = 10
else:
    ans = sum(map(int, list(str(n))))
print(ans)

-def d_sum(x): -    res = 0 -    while x > 0: -        res += x % 10 -        x //= 10 -    return res - +from math import log -ans = float("inf") -for a in range(1, n // 2 + 1): -    b = n - a -    ans = min(ans, d_sum(a) + d_sum(b)) +if log(n, 10) % 1 == 0: +    ans = 10 +else: +    ans = sum(map(int, list(str(n))))