n = int(eval(input()))



if n%10 == 0 and n != 10:

    print((10))

else:

    a,b = 1,0

    sA, sB= 0,0

    soma = []



    while a<=n:

        b=n-a



        for i in str(a):

            sA+=int(i)

        for j in str(b):

            sB+=int(j)

        soma.append(sA+sB)

    

        a=a+1

    print((min(soma)))

def main():

    n = int(eval(input()))

    a = n - 1

    b = 1

    menor = soma_digitos(a) + soma_digitos(b)

    temp = 0

    for i in range(n-2):

        a -= 1

        b += 1

        temp = soma_digitos(a) + soma_digitos(b)

        if menor > temp:

            menor = temp

    print(menor)



def soma_digitos(n):

    soma = 0

    while n >= 1:

        soma += n%10

        n = n//10

    return soma

main()
n = int(eval(input()))
if n % 10 == 0 and n != 10:
    print((10))
else:
    a, b = 1, 0
    sA, sB = 0, 0
    soma = []
    while a <= n:
        b = n - a
        for i in str(a):
            sA += int(i)
        for j in str(b):
            sB += int(j)
        soma.append(sA + sB)
        a = a + 1
    print((min(soma)))

def main():
    n = int(eval(input()))
    a = n - 1
    b = 1
    menor = soma_digitos(a) + soma_digitos(b)
    temp = 0
    for i in range(n - 2):
        a -= 1
        b += 1
        temp = soma_digitos(a) + soma_digitos(b)
        if menor > temp:
            menor = temp
    print(menor)


def soma_digitos(n):
    soma = 0
    while n >= 1:
        soma += n % 10
        n = n // 10
    return soma


main()

-n = int(eval(input())) -if n % 10 == 0 and n != 10: -    print((10)) -else: -    a, b = 1, 0 -    sA, sB = 0, 0 -    soma = [] -    while a <= n: -        b = n - a -        for i in str(a): -            sA += int(i) -        for j in str(b): -            sB += int(j) -        soma.append(sA + sB) -        a = a + 1 -    print((min(soma))) +def main(): +    n = int(eval(input())) +    a = n - 1 +    b = 1 +    menor = soma_digitos(a) + soma_digitos(b) +    temp = 0 +    for i in range(n - 2): +        a -= 1 +        b += 1 +        temp = soma_digitos(a) + soma_digitos(b) +        if menor > temp: +            menor = temp +    print(menor) + + +def soma_digitos(n): +    soma = 0 +    while n >= 1: +        soma += n % 10 +        n = n // 10 +    return soma + + +main()