N = int(eval(input()))



result = 10 ** 10



for a in range(1, N):

    b = N - a

    A = 0

    while a != 0:

        A += a % 10

        a = a // 10

    B = 0

    while b != 0:

        B += b % 10

        b = b // 10



    result = min(result, A + B)



print(result)
def digit_sum(n):

    result = 0

    while n > 0:

        result += n % 10

        n = n // 10

    return result



N = int(eval(input()))

mi = 1e10

for i in range(1, N):

    mi = min(mi, digit_sum(i) + digit_sum(N - i))

print(mi)

N = int(eval(input()))
result = 10**10
for a in range(1, N):
    b = N - a
    A = 0
    while a != 0:
        A += a % 10
        a = a // 10
    B = 0
    while b != 0:
        B += b % 10
        b = b // 10
    result = min(result, A + B)
print(result)

def digit_sum(n):
    result = 0
    while n > 0:
        result += n % 10
        n = n // 10
    return result


N = int(eval(input()))
mi = 1e10
for i in range(1, N):
    mi = min(mi, digit_sum(i) + digit_sum(N - i))
print(mi)

+def digit_sum(n): +    result = 0 +    while n > 0: +        result += n % 10 +        n = n // 10 +    return result + + -result = 10**10 -for a in range(1, N): -    b = N - a -    A = 0 -    while a != 0: -        A += a % 10 -        a = a // 10 -    B = 0 -    while b != 0: -        B += b % 10 -        b = b // 10 -    result = min(result, A + B) -print(result) +mi = 1e10 +for i in range(1, N): +    mi = min(mi, digit_sum(i) + digit_sum(N - i)) +print(mi)