local floor = math.floor
local min = math.min
local N = io.read("*n")

local function idiv(operand1, operand2)
	return floor(operand1 / operand2)
end

local function sumDigits(num)
	local sum = 0
	while num > 0 do
		sum = sum + num % 10
		num = idiv(num, 10)
	end
	return sum
end

local out = 100001
for A = 1, idiv(N, 2) do
	local B = N - A
	local sum = sumDigits(A) + sumDigits(B)
	out = min(out, sum)
end

print(out)
