#!/usr/bin/env python



n = int(eval(input()))



def sumdigits(n):

    ret = 0 

    s = list(str(n))

    for i in range(len(s)):

        ret += int(s[i])

    return ret 



a = 1 

ans = 1000000

while n-a > 0:

    tmp = sumdigits(a) + sumdigits(n-a)

    if ans >= tmp:

        ans = tmp 

    a += 1



print(ans)

#!/usr/bin/env python

import math



n = int(eval(input()))

m = math.log10(n)

if int(m) == m:

    print((10))

    exit()



ans = sum(map(int, list(str(n))))

print(ans)

#!/usr/bin/env python
n = int(eval(input()))


def sumdigits(n):
    ret = 0
    s = list(str(n))
    for i in range(len(s)):
        ret += int(s[i])
    return ret


a = 1
ans = 1000000
while n - a > 0:
    tmp = sumdigits(a) + sumdigits(n - a)
    if ans >= tmp:
        ans = tmp
    a += 1
print(ans)

#!/usr/bin/env python
import math

n = int(eval(input()))
m = math.log10(n)
if int(m) == m:
    print((10))
    exit()
ans = sum(map(int, list(str(n))))
print(ans)

+import math + - - -def sumdigits(n): -    ret = 0 -    s = list(str(n)) -    for i in range(len(s)): -        ret += int(s[i]) -    return ret - - -a = 1 -ans = 1000000 -while n - a > 0: -    tmp = sumdigits(a) + sumdigits(n - a) -    if ans >= tmp: -        ans = tmp -    a += 1 +m = math.log10(n) +if int(m) == m: +    print((10)) +    exit() +ans = sum(map(int, list(str(n))))