Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim ans As Integer = Integer.MaxValue

        For a As Integer = 1 To n - 1
            Dim b As Integer = n - a
            ans = Math.Min(ans, DigitsSum(a) + DigitsSum(b))
        Next
        WriteLine(ans)
    End Sub

    Function DigitsSum(x As Integer) As Integer
        Dim result As Integer
        Do While x <> 0
            result += x Mod 10
            x = x \ 10
        Loop

        Return result
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module
