#include <iostream>
using namespace std;

int calcdigit(int a){
    int sum = 0;
    while(a >= 10){
         int r = a%10;
         int a = a/10;
         sum = sum + r;
    }
    sum = sum + a;
    return sum;
}

int calcSum(int a){
    int a1 = a/2;
    int a2 = a - a1;
    int min = a;
    for (;a1>1;;){
       int ret = calcdigit(a1) + calcdigit(a2);
       if (ret < min ){
            min = ret;
       }
       a1--;
       a2++;
    }
    return min;
}

int main(){
    int a;
    cin >> a ;
    int c = calcSum(a);
    cout << c;
    return 0;
}