N = int(eval(input()))



def f(k):

    s = str(k)

    n = len(s)

    ans = 0

    for i in range(n):

        ans += int(s[i])

    return ans



ans = float("INF")

for i in range(1, N):

    j = N-i

    t = f(i) + f(j)

    ans = min(ans, t)



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



def f(n):

    ans = 0

    for s in str(n):

        ans += int(s)

    return ans



ans = float("INF")

for i in range(1, N):

    j = N-i

    ans = min(ans, f(i) + f(j))

    

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


def f(k):
    s = str(k)
    n = len(s)
    ans = 0
    for i in range(n):
        ans += int(s[i])
    return ans


ans = float("INF")
for i in range(1, N):
    j = N - i
    t = f(i) + f(j)
    ans = min(ans, t)
print(ans)

N = int(eval(input()))


def f(n):
    ans = 0
    for s in str(n):
        ans += int(s)
    return ans


ans = float("INF")
for i in range(1, N):
    j = N - i
    ans = min(ans, f(i) + f(j))
print(ans)

-def f(k): -    s = str(k) -    n = len(s) +def f(n): -    for i in range(n): -        ans += int(s[i]) +    for s in str(n): +        ans += int(s) -    t = f(i) + f(j) -    ans = min(ans, t) +    ans = min(ans, f(i) + f(j))