#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, ans = 1e9;
void solve()
{
    cin >> n;
    for( int i = 1; i < n; i ++ )
    {
        ll x = i, z = n - i, sx = 0, sz = 0;
        while( x )sx += x % 10, x /= 10;
        while( z )sz += z % 10, z /= 10;
        ans = min( ans, sz + sx );
    }
    cout << ans;
}
int main()
{

	/*cin >> tests;
	while( t -- )*/
	    solve();
}