n = int(eval(input()))



def find(a):

    global total

    total = 0

    while a > 0:

        total += a % 10

        a //= 10

    return total



ans = float('inf')

for i in range(1,n):

    tmp = find(i) + find(n-i)

    ans = min(ans, tmp)

print(ans)
def findSumOfDigits(n):

    sum = 0

    while n > 0:

        sum += n % 10

        n //= 10

    return sum



n = int(eval(input()))

minTotal = float('inf')

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

    if 0 < n - i < n:

        a = findSumOfDigits(i)

        b = findSumOfDigits(n-i)

        if a + b < minTotal:

            minTotal = a + b

print(minTotal)
n = int(eval(input()))


def find(a):
    global total
    total = 0
    while a > 0:
        total += a % 10
        a //= 10
    return total


ans = float("inf")
for i in range(1, n):
    tmp = find(i) + find(n - i)
    ans = min(ans, tmp)
print(ans)

def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum


n = int(eval(input()))
minTotal = float("inf")
for i in range(1, n + 1):
    if 0 < n - i < n:
        a = findSumOfDigits(i)
        b = findSumOfDigits(n - i)
        if a + b < minTotal:
            minTotal = a + b
print(minTotal)

-n = int(eval(input())) +def findSumOfDigits(n): +    sum = 0 +    while n > 0: +        sum += n % 10 +        n //= 10 +    return sum -def find(a): -    global total -    total = 0 -    while a > 0: -        total += a % 10 -        a //= 10 -    return total - - -ans = float("inf") -for i in range(1, n): -    tmp = find(i) + find(n - i) -    ans = min(ans, tmp) -print(ans) +n = int(eval(input())) +minTotal = float("inf") +for i in range(1, n + 1): +    if 0 < n - i < n: +        a = findSumOfDigits(i) +        b = findSumOfDigits(n - i) +        if a + b < minTotal: +            minTotal = a + b +print(minTotal)