#include<algorithm>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn=1e6;
int fun(int n){
    int sum=0;
    while(n){
        sum+=(n%10);
        n/=10;
    }
    return sum;
}
int main()
{
    int n;
    cin>>n;
    int minn=inf;
    for(int i=1;i<=n/2;i++){
        int sum=fun(i)+fun(n-i);
        if(minn>sum)
            minn=sum;
    }
    cout<<minn<<endl;
    return 0;
}
