def func(x):

    if x // 10 == 0:

        return x

    else:

        return x % 10 + func(x // 10)



n = int(eval(input()))

ans = float('inf')

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

    ans = min(ans, func(a) + func(n - a))

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)
def func(x):
    if x // 10 == 0:
        return x
    else:
        return x % 10 + func(x // 10)


n = int(eval(input()))
ans = float("inf")
for a in range(1, (n // 2) + 1):
    ans = min(ans, func(a) + func(n - a))
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)

-def func(x): -    if x // 10 == 0: -        return x -    else: -        return x % 10 + func(x // 10) +def d_sum(x): +    res = 0 +    while x > 0: +        res += x % 10 +        x //= 10 +    return res -for a in range(1, (n // 2) + 1): -    ans = min(ans, func(a) + func(n - a)) +for a in range(1, n // 2 + 1): +    b = n - a +    ans = min(ans, d_sum(a) + d_sum(b))