#include <bits/stdc++.h>

using namespace std;
int n;
int main (){
    cin >> n;
    int mn = 1e9;
    for(int i = 1; i < n; i++){
        int j = n - i;
        int j2 = i;
        int sum = 0;
        while(j > 0){
            sum += j % 10;
            j /= 10;
        }
        while(j2 > 0){
            sum += j2 % 10;
            j2 /= 10;
        }
        mn = min(sum, mn);
    }
    cout << mn;
}
