#include<stdio.h>
int main()
{
	int n,a,b,min=99999999,qwq[100005];
	scanf("%d",&n);
	for(b=1;b<n;b++)
	{
		a=b;
		qwq[b]=a/100000;
		a%=100000;
		qwq[b]+=a/10000;
		a%=10000;
		qwq[b]+=a/1000;
		a%=1000;
		qwq[b]+=a/100;
		a%=100;
		qwq[b]+=a/10;
		a%=10;
		qwq[b]+=a;
	}
	for(a=1;a<=n/2+1;a++)
	{
		if(qwq[a]+qwq[n-a]<min)
		min=qwq[a]+qwq[n-a];
	}
	printf("%d",min);
}