#include <bits/stdc++.h>

#define out(x) printf("%lld",x)
#define in(x) scanf("%lld",&x)
#define puts() printf("\n")
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front           
#define pbp pop_back
#define pfp pop_front
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define rep(i,b,e) for(int i=b;i<=e;++i)
#define per(i,b,e) for(int i=b;i>=e;--i)
#define sz size()   
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string S;                                                                
typedef double D;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<pair<int,int> >VII;
typedef map<int,int> MII;

const S ou = " ";
const int N = 1e5 + 17;
const int mod = 1e9 + 7;
const int INF = 2e9 - 19;

ll MX=(ll)1e10,MN=(ll)-1e10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

///////////////////////////////////
//Best code from Asanaly Serekbay//
///////////////////////////////////
//
//	Suported by Google Taxi & Yandex Taxi & Indriver & IOI
//
//  Checked by Zeus & Phantom Assasin
//

int mn = MX ;

int get_sum( int n ){
		
		int ans = 0 ;

		while( n ){
			ans += n % 10 ;
			n/= 10 ;
		} 
		return ans ;
}
int q , w ;
                        
int main(){
 #ifdef BloodCandy
 			cout<<"Welcome my lord ^_^\n";
			//fr("test");
 #endif

 int n ;

 cin >> n ;


for( int i = 1 ; i < n ; ++i ){
 
 		   if( mn > get_sum(i) + get_sum( n - i ) ) mn = get_sum(i) + get_sum( n - i );
 }

 cout << mn;

 return 0;


}