#include<iostream>
using namespace std;

long long sumdig(long A)
{
    long long sum=0,rem;

    while(A>0)
    {
        rem=A%10;
        A=A/10;
        sum+=rem;
    }

    return sum;
}

int main()
{
    long int N,A,B; long long ans=INT_MAX;
    cin>>N;
    A=1;
    B=N-A;

    while(B>= N/2)
    {
      ans= min(ans,sumdig(A) + sumdig(B));

      A=A+1;
      B=B-1;
    }

    cout<<ans;
}
