N = int(eval(input()))



def SumDigits(num):

    sum = 0

    while True:

        sum += num % 10

        num //= 10

        if num == 0:

            break

    return sum



infinity = float('inf')

min = infinity



for x in range(1, N):

    if SumDigits(x) + SumDigits(N - x) < min:

        min = SumDigits(x) + SumDigits(N - x)

print(min)

N = int(eval(input()))



def SumDigits(num):

    sum = 0

    while True:

        sum += num % 10

        num //= 10

        if num == 0:

            break

    return sum



infinity = float('inf')

min = infinity



for x in range(1, N//2 + 1):

    #print('============')

    #print(x, N - x)

    #print(SumDigits(x) + SumDigits(N - x))

    if SumDigits(x) + SumDigits(N - x) < min:

        min = SumDigits(x) + SumDigits(N - x)

print(min)

N = int(eval(input()))


def SumDigits(num):
    sum = 0
    while True:
        sum += num % 10
        num //= 10
        if num == 0:
            break
    return sum


infinity = float("inf")
min = infinity
for x in range(1, N):
    if SumDigits(x) + SumDigits(N - x) < min:
        min = SumDigits(x) + SumDigits(N - x)
print(min)

N = int(eval(input()))


def SumDigits(num):
    sum = 0
    while True:
        sum += num % 10
        num //= 10
        if num == 0:
            break
    return sum


infinity = float("inf")
min = infinity
for x in range(1, N // 2 + 1):
    # print('============')
    # print(x, N - x)
    # print(SumDigits(x) + SumDigits(N - x))
    if SumDigits(x) + SumDigits(N - x) < min:
        min = SumDigits(x) + SumDigits(N - x)
print(min)

-for x in range(1, N): +for x in range(1, N // 2 + 1): +    # print('============') +    # print(x, N - x) +    # print(SumDigits(x) + SumDigits(N - x))