#import <Foundation/Foundation.h>
typedef NSInteger Int;
Int f(Int x){
	Int result = 0;
	while(x>0){
		result += x%10;
		x/=10;
	}
	return result;
}
int main() {
	Int n;
	scanf("%ld",&n);
	Int ans = NSIntegerMax;
	for(Int a=1;a<=(n+1)/2;a++){
		Int b = n-a;
		ans = MIN(ans, f(a)+f(b));
	}
	printf("%ld\n",ans);
}