def main():

    N = int(eval(input()))



    total = float('inf')

    for a in range(1, N):

        b = N - a

        n = 0

        while a > 0:

            n += a % 10

            a //= 10

        while b > 0:

            n += b % 10

            b //= 10

        total = min(total, n)



    print(total)



main()

def main():

    N = int(eval(input()))



    ans = 0

    while N > 0:

        ans += N % 10

        N //= 10

    if ans == 1:

        print((10))

    else:

        print(ans)



main()

def main():
    N = int(eval(input()))
    total = float("inf")
    for a in range(1, N):
        b = N - a
        n = 0
        while a > 0:
            n += a % 10
            a //= 10
        while b > 0:
            n += b % 10
            b //= 10
        total = min(total, n)
    print(total)


main()

def main():
    N = int(eval(input()))
    ans = 0
    while N > 0:
        ans += N % 10
        N //= 10
    if ans == 1:
        print((10))
    else:
        print(ans)


main()

-    total = float("inf") -    for a in range(1, N): -        b = N - a -        n = 0 -        while a > 0: -            n += a % 10 -            a //= 10 -        while b > 0: -            n += b % 10 -            b //= 10 -        total = min(total, n) -    print(total) +    ans = 0 +    while N > 0: +        ans += N % 10 +        N //= 10 +    if ans == 1: +        print((10)) +    else: +        print(ans)