local n = io.read("*n")
local hn = n // 2

local function get(x)
  local r = 0
  while 0 < x do
    r = r + x % 10
    x = x // 10
  end
  return r
end
local mmi = math.min
local ret = get(1) + get(n - 1)
for i = 2, hn do
  ret = mmi(ret, get(i) + get(n - i))
end
print(ret)
