# B 

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

nl = lambda: list(map(int, input().split()))

def calc(a,b):

    sa=list(str(a))

    sb=list(str(b))

    res=0

    for aa in sa:

        res+=int(aa)

    for bb in sb:

        res+=int(bb)

    return res



n=ni()

ans=10**6

for i in range(1,n):

    a=i

    b=n-i

    t=calc(a,b)

    ans=min(ans,t)

print(ans)



n=int(eval(input()))

ans=10**18

for a in range(1,n):

  b=n-a

  tmp=0

  for aa in str(a):

    tmp+=int(aa)

  for bb in str(b):

    tmp+=int(bb)

  ans=min(ans,tmp)

print(ans)
# B
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))


def calc(a, b):
    sa = list(str(a))
    sb = list(str(b))
    res = 0
    for aa in sa:
        res += int(aa)
    for bb in sb:
        res += int(bb)
    return res


n = ni()
ans = 10**6
for i in range(1, n):
    a = i
    b = n - i
    t = calc(a, b)
    ans = min(ans, t)
print(ans)

n = int(eval(input()))
ans = 10**18
for a in range(1, n):
    b = n - a
    tmp = 0
    for aa in str(a):
        tmp += int(aa)
    for bb in str(b):
        tmp += int(bb)
    ans = min(ans, tmp)
print(ans)

-# B -si = lambda: eval(input()) -ni = lambda: int(eval(input())) -nm = lambda: list(map(int, input().split())) -nl = lambda: list(map(int, input().split())) - - -def calc(a, b): -    sa = list(str(a)) -    sb = list(str(b)) -    res = 0 -    for aa in sa: -        res += int(aa) -    for bb in sb: -        res += int(bb) -    return res - - -n = ni() -ans = 10**6 -for i in range(1, n): -    a = i -    b = n - i -    t = calc(a, b) -    ans = min(ans, t) +n = int(eval(input())) +ans = 10**18 +for a in range(1, n): +    b = n - a +    tmp = 0 +    for aa in str(a): +        tmp += int(aa) +    for bb in str(b): +        tmp += int(bb) +    ans = min(ans, tmp)