def sum_of_digits(n):

	mod=0

	num=[]

	while n !=0:

		mod=n%10

		n=n//10

		num.append(mod)

	return (sum(num))



N=int(eval(input()))

sum_of_all =0

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

	sum1=sum_of_digits(i)

	sum2=sum_of_digits(N-i)

	sum_of_all=sum1+sum2

	if i ==1:

		ans=sum_of_all

	elif ans>sum_of_all:

		ans=sum_of_all

print(ans)

		

	
def dig_sum(N):

    ans=0

    while N>0:

        ans+=N%10

        N=N//10

    return ans



N=int(eval(input()))

ans=100

for i in range(1,N):

    tmp=dig_sum(i)+dig_sum(N-i)

    if tmp<ans:

        ans=tmp

print(ans)

def sum_of_digits(n):
    mod = 0
    num = []
    while n != 0:
        mod = n % 10
        n = n // 10
        num.append(mod)
    return sum(num)


N = int(eval(input()))
sum_of_all = 0
for i in range(1, N // 2 + 2):
    sum1 = sum_of_digits(i)
    sum2 = sum_of_digits(N - i)
    sum_of_all = sum1 + sum2
    if i == 1:
        ans = sum_of_all
    elif ans > sum_of_all:
        ans = sum_of_all
print(ans)

def dig_sum(N):
    ans = 0
    while N > 0:
        ans += N % 10
        N = N // 10
    return ans


N = int(eval(input()))
ans = 100
for i in range(1, N):
    tmp = dig_sum(i) + dig_sum(N - i)
    if tmp < ans:
        ans = tmp
print(ans)

-def sum_of_digits(n): -    mod = 0 -    num = [] -    while n != 0: -        mod = n % 10 -        n = n // 10 -        num.append(mod) -    return sum(num) +def dig_sum(N): +    ans = 0 +    while N > 0: +        ans += N % 10 +        N = N // 10 +    return ans -sum_of_all = 0 -for i in range(1, N // 2 + 2): -    sum1 = sum_of_digits(i) -    sum2 = sum_of_digits(N - i) -    sum_of_all = sum1 + sum2 -    if i == 1: -        ans = sum_of_all -    elif ans > sum_of_all: -        ans = sum_of_all +ans = 100 +for i in range(1, N): +    tmp = dig_sum(i) + dig_sum(N - i) +    if tmp < ans: +        ans = tmp