import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int digits(int n) {
    if (n == 0) return 0;

    int x = 0;
    while (n > 0) {
        x += n % 10;
        n /= 10;
    }
    return x;
}

int calc(int n) {

    int ans = int.max;
    for (int i = 1; i < n; i++) {
        int a = i;
        int b = n - a;

        ans = min(ans, digits(a) + digits(b));
    }
    return ans;
}

void main() {
    int n = readint;
    auto ans = calc(n);
    writeln(ans);
}