N = int(eval(input()))



ans = float('inf')

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

    b = N - a



    t = 0

    while a > 0:

        a, r = divmod(a, 10)

        t += r



    while b > 0:

        b, r = divmod(b, 10)

        t += r



    ans = min(t, ans)

print(ans)

N = int(eval(input()))





def f(x):

    ret = 0

    while x:

        x, r = divmod(x, 10)

        ret += r

    return ret





ret = 10 ** 9

for a in range(1, N):

    b = N - a

    ret = min(ret, f(a) + f(b))

print(ret)

N = int(eval(input()))
ans = float("inf")
for a in range(1, N // 2 + 1):
    b = N - a
    t = 0
    while a > 0:
        a, r = divmod(a, 10)
        t += r
    while b > 0:
        b, r = divmod(b, 10)
        t += r
    ans = min(t, ans)
print(ans)

N = int(eval(input()))


def f(x):
    ret = 0
    while x:
        x, r = divmod(x, 10)
        ret += r
    return ret


ret = 10**9
for a in range(1, N):
    b = N - a
    ret = min(ret, f(a) + f(b))
print(ret)

-ans = float("inf") -for a in range(1, N // 2 + 1): + + +def f(x): +    ret = 0 +    while x: +        x, r = divmod(x, 10) +        ret += r +    return ret + + +ret = 10**9 +for a in range(1, N): -    t = 0 -    while a > 0: -        a, r = divmod(a, 10) -        t += r -    while b > 0: -        b, r = divmod(b, 10) -        t += r -    ans = min(t, ans) -print(ans) +    ret = min(ret, f(a) + f(b)) +print(ret)