n=int(eval(input()))

ans=n

for i in range(1,n):

  l=[int(j) for j in list(str(i))]

  m=[int(k) for k in list(str(abs(n-i)))]

  if ans>sum(l)+sum(m):

    ans=sum(l)+sum(m)

print(ans)
# A

NL = list(map(int, list(eval(input()))))



if NL[0] == 1 and sum(NL) == 1:

    print((10))

else:

    print((sum(NL)))

#copy code
n = int(eval(input()))
ans = n
for i in range(1, n):
    l = [int(j) for j in list(str(i))]
    m = [int(k) for k in list(str(abs(n - i)))]
    if ans > sum(l) + sum(m):
        ans = sum(l) + sum(m)
print(ans)

# A
NL = list(map(int, list(eval(input()))))
if NL[0] == 1 and sum(NL) == 1:
    print((10))
else:
    print((sum(NL)))
# copy code

-n = int(eval(input())) -ans = n -for i in range(1, n): -    l = [int(j) for j in list(str(i))] -    m = [int(k) for k in list(str(abs(n - i)))] -    if ans > sum(l) + sum(m): -        ans = sum(l) + sum(m) -print(ans) +# A +NL = list(map(int, list(eval(input())))) +if NL[0] == 1 and sum(NL) == 1: +    print((10)) +else: +    print((sum(NL))) +# copy code