#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define met(a,b) memset(a,b,sizeof(a))

int solve(int n)
{
    int ans=0;
    while(n){
        ans+=n%10;
        n/=10;
    }
    return ans;
}

int main()
{
    int n,Min=inf;
    scanf("%d",&n);
    for(int i=1;i<=n/2;i++){
        Min=min(Min,solve(i)+solve(n-i));
    }
    printf("%d\n",Min);
    return 0;
}