#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int get_sum(int x)
{
	int f=0;
	while(x>0)
	{
		f+=(x%10);
		x/=10;
	}
	return f;
}
int main()
{
	
	int n;
	scanf("%d",&n);
	int ans=0x3f3f3f3f;
	for(int i=2;i<n;i++)
		ans=min(ans,get_sum(i)+get_sum(n-i));
	printf("%d",ans);
	return 0;
}