import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long n = read.to!long;
	
	long best = 1_000_000_999;
	long[] ms = [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000];
	foreach(i; 1 .. n){
		long a = i;
		long b = n - a;
		long x;
		while(a > 0 || b > 0){
			x += a % 10, a /= 10;
			x += b % 10, b /= 10;
		}
		best = min(best, x);
	}
	
	best.writeln;
}
