import sys



def digits_sum(x):

    return sum(list(map(int, str(x))))



def solve(n):

    ans = sys.maxsize

    for a in range(1, n):

        b = n - a

        ans = min(ans, digits_sum(a) + digits_sum(b))



    return ans



if __name__ == '__main__':

    n = int(eval(input()))

    print((solve(n)))

import sys



def digits_sum(x):

    return sum(map(int, str(x)))



def solve(n):

    ans = sys.maxsize

    for a in range(1, n):

        b = n - a

        ans = min(ans, digits_sum(a) + digits_sum(b))



    return ans



if __name__ == '__main__':

    n = int(eval(input()))

    print((solve(n)))

import sys


def digits_sum(x):
    return sum(list(map(int, str(x))))


def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))
    return ans


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve(n)))

import sys


def digits_sum(x):
    return sum(map(int, str(x)))


def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))
    return ans


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve(n)))

-    return sum(list(map(int, str(x)))) +    return sum(map(int, str(x)))