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()

def slove():

    import sys

    input = sys.stdin.readline

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

    mt = 10 ** 20

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

        sa = str(i)

        sb = str(n - i)

        t = 0

        for j in range(len(sa)):

            t += int(sa[j])

        for j in range(len(sb)):

            t += int(sb[j])

        mt = min(mt, t)

    print(mt)





if __name__ == '__main__':

    slove()

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()

def slove():
    import sys

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    mt = 10**20
    for i in range(1, n // 2 + 1):
        sa = str(i)
        sb = str(n - i)
        t = 0
        for j in range(len(sa)):
            t += int(sa[j])
        for j in range(len(sb)):
            t += int(sb[j])
        mt = min(mt, t)
    print(mt)


if __name__ == "__main__":
    slove()

-    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) +    mt = 10**20 +    for i in range(1, n // 2 + 1): +        sa = str(i) +        sb = str(n - i) +        t = 0 +        for j in range(len(sa)): +            t += int(sa[j]) +        for j in range(len(sb)): +            t += int(sb[j]) +        mt = min(mt, t) +    print(mt)