program AGC025A
    implicit none
    integer(8)::N,A,B,i,ans,dig
    read*,N
    ans=9999999

    do i=1,N-1
        A=i
        B=N-i
        dig=0
        do
            dig=dig+mod(A,10)
            A=A/10
            if(A==0)exit
        end do

        do
            dig=dig+mod(B,10)
            B=B/10
            if(B==0)exit
        end do
        ans=min(ans,dig)
    end do

    print'(i0)',ans
end program AGC025A