# AGC 025: A – Digits Sum

n = int(eval(input()))

answer = 999999999



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

    num_A = str(i)

    num_B = str(n - i)



    sum_digits_A = sum([int(j) for j in num_A])

    sum_digits_B = sum([int(j) for j in num_B])



    answer = min(answer, sum_digits_A + sum_digits_B)



print(answer)
# AGC 025: A – Digits Sum

N = int(eval(input()))

n = N // 2 if N % 2 == 0 else N // 2 + 1

min_sum = 9999



for i in range(1, n + 1):

    sum_digits = 0

    A = i

    B = N - i



    while A != 0:

        sum_digits += A % 10

        A //= 10

    

    while B != 0:

        sum_digits += B % 10

        B //= 10

        

    min_sum = min(min_sum, sum_digits)



print(min_sum)
# AGC 025: A – Digits Sum
n = int(eval(input()))
answer = 999999999
for i in range(1, n // 2 + 1):
    num_A = str(i)
    num_B = str(n - i)
    sum_digits_A = sum([int(j) for j in num_A])
    sum_digits_B = sum([int(j) for j in num_B])
    answer = min(answer, sum_digits_A + sum_digits_B)
print(answer)

# AGC 025: A – Digits Sum
N = int(eval(input()))
n = N // 2 if N % 2 == 0 else N // 2 + 1
min_sum = 9999
for i in range(1, n + 1):
    sum_digits = 0
    A = i
    B = N - i
    while A != 0:
        sum_digits += A % 10
        A //= 10
    while B != 0:
        sum_digits += B % 10
        B //= 10
    min_sum = min(min_sum, sum_digits)
print(min_sum)

-n = int(eval(input())) -answer = 999999999 -for i in range(1, n // 2 + 1): -    num_A = str(i) -    num_B = str(n - i) -    sum_digits_A = sum([int(j) for j in num_A]) -    sum_digits_B = sum([int(j) for j in num_B]) -    answer = min(answer, sum_digits_A + sum_digits_B) -print(answer) +N = int(eval(input())) +n = N // 2 if N % 2 == 0 else N // 2 + 1 +min_sum = 9999 +for i in range(1, n + 1): +    sum_digits = 0 +    A = i +    B = N - i +    while A != 0: +        sum_digits += A % 10 +        A //= 10 +    while B != 0: +        sum_digits += B % 10 +        B //= 10 +    min_sum = min(min_sum, sum_digits) +print(min_sum)