def digits_sum(n):

    return sum(int(c) for c in str(n))





N = int(eval(input()))

ans = float("inf")

for i in range(1, N):

    A = i

    B = N - i

    ans = min(ans, digits_sum(A) + digits_sum(B))

print(ans)

def digit_sum(x):

    res = 0

    while x > 0:

        res += x % 10

        x //= 10

    return res





N = int(eval(input()))

ans = N

for i in range(1, N):

    A = i

    B = N - i

    ans = min(ans, digit_sum(A) + digit_sum(B))

print(ans)

def digits_sum(n):
    return sum(int(c) for c in str(n))


N = int(eval(input()))
ans = float("inf")
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digits_sum(A) + digits_sum(B))
print(ans)

def digit_sum(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res


N = int(eval(input()))
ans = N
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digit_sum(A) + digit_sum(B))
print(ans)

-def digits_sum(n): -    return sum(int(c) for c in str(n)) +def digit_sum(x): +    res = 0 +    while x > 0: +        res += x % 10 +        x //= 10 +    return res -ans = float("inf") +ans = N -    ans = min(ans, digits_sum(A) + digits_sum(B)) +    ans = min(ans, digit_sum(A) + digit_sum(B))