n = int(eval(input()))

mt = 10 ** 9

for i in range(1, n):

    t = 0

    for j in range(len(str(i))):

        t += int(str(i)[j])

    for j in range(len(str(n - i))):

        t += int(str(n - i)[j])

    mt = min(mt, t)

print(mt)

def slove():

    import sys

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    m_t = 10 ** 10

    for i in range(1, n):

        a = list(map(int, list(str(i))))

        b = list(map(int, list(str(n-i))))

        m_t = min(m_t, sum(a) + sum(b))

    print(m_t)





if __name__ == '__main__':

    slove()

n = int(eval(input()))
mt = 10**9
for i in range(1, n):
    t = 0
    for j in range(len(str(i))):
        t += int(str(i)[j])
    for j in range(len(str(n - i))):
        t += int(str(n - i)[j])
    mt = min(mt, t)
print(mt)

def slove():
    import sys

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    m_t = 10**10
    for i in range(1, n):
        a = list(map(int, list(str(i))))
        b = list(map(int, list(str(n - i))))
        m_t = min(m_t, sum(a) + sum(b))
    print(m_t)


if __name__ == "__main__":
    slove()

-n = int(eval(input())) -mt = 10**9 -for i in range(1, n): -    t = 0 -    for j in range(len(str(i))): -        t += int(str(i)[j]) -    for j in range(len(str(n - i))): -        t += int(str(n - i)[j]) -    mt = min(mt, t) -print(mt) +def slove(): +    import sys + +    input = sys.stdin.readline +    n = int(input().rstrip("\n")) +    m_t = 10**10 +    for i in range(1, n): +        a = list(map(int, list(str(i)))) +        b = list(map(int, list(str(n - i)))) +        m_t = min(m_t, sum(a) + sum(b)) +    print(m_t) + + +if __name__ == "__main__": +    slove()