#include <bits/stdc++.h> 

using namespace std;

#define rep(i,n) for(long long int i=0;i<n;i++)
#define rep1(i,n) for(long long int i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(long long int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(long long int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define pf printf
#define sf scanf
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define vci(v) for(long long int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(long long int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mp make_pair
#define fir first
#define sec second
#define clr(arr) memset((arr),0,sizeof(arr))

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vb;
typedef vector<vector<double>> vvd;
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
typedef pair<int,int> pii;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};
const long double Pi=3.141592653589793238462643383279502884197;
const long double Napier=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T,typename U>                                                   
inline pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template<typename T> inline void Swap(T *x,T *y){ T tem=*x; *x=*y; *y=tem; }

inline long long int rem(long long int n,long long int m){
	if(!m) return 0;
	return (n<0?(n%m)+m:(n%m));
}

/*
int thre1,thre2;
vi v;

template<typename T> inline bool judge(T n){
	return (thre1<=v[n]&&thre2>=v[n]);
}

template<typename T> inline T BiS(T bottom,T ceiling,bool thretype){
	T upper=ceiling+thretype;
	T lower=bottom-(!thretype);
	while(upper-lower>1){
		T mid=(upper+lower)/2;
		if(judge(mid)) (thretype?lower:upper)=mid;
		else (thretype?upper:lower)=mid;
	}
	return (thretype?lower:upper);
}
*/

/* The main code follows below */

int N;

void input(){
	cin>>N;
	return;
}

void solve(){
	int ans=Inf;
	rep1(i,N/2){
		int S=0;
		int k=N-i;
		int l=i;
		repD(j,5,0){
			int a=l/(pow(10,j));
			int b=k/(pow(10,j));
			l-=a*pow(10,j);
			k-=b*pow(10,j);
			S+=a+b;
		}
		ans=min(ans,S);
	}
	cout<<ans<<endl;
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	input();
	solve();
	return 0;
}


Measured memory_bytes: 512