#include<stdio.h>
#include<string.h>
int main()
{
    int i,a[100001],N;
    int sum=0,t,x;
    scanf("%d",&N);
    memset(a,0,sizeof(a));
    for(i=1;i<=N/2;i++)
    {
        t=i;
        x=N-t;
        sum=0;
        while(t>0)
        {
            sum+=t%10;
            t/=10;
        }
        while(x>0)
        {
            sum+=x%10;
            x/=10;
        }
        a[i]=sum;

    }
    int minn=999999;
    for(i=1;i<=N/2;i++)
        if(a[i]<minn)
        minn=a[i];

printf("%d\n",minn);
}
