N=int(eval(input()))

def f(x):

  s=0

  while x!=0:

    s+=x%10

    x//=10

  return(s)

minn=50

for i in range(1,N):

  minn=min(f(i)+f(N-i),minn)

print(minn)
N=int(eval(input()))

def f(x):

  s=0

  while x!=0:

    s+=x%10

    x//=10

  return(s)

minn=50

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

  minn=min(f(i)+f(N-i),minn)

print(minn)
N = int(eval(input()))


def f(x):
    s = 0
    while x != 0:
        s += x % 10
        x //= 10
    return s


minn = 50
for i in range(1, N):
    minn = min(f(i) + f(N - i), minn)
print(minn)

N = int(eval(input()))


def f(x):
    s = 0
    while x != 0:
        s += x % 10
        x //= 10
    return s


minn = 50
for i in range(1, N // 2 + 1):
    minn = min(f(i) + f(N - i), minn)
print(minn)

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