#include <bits/stdc++.h>

#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef int I;

const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const int inf = 1e9 + 123;
const long long INF = 1e18;
const double eps = 1e-5;
int n, t;
ll a[N], ans;

int f(int x){
	int s = 0;
	while(x){
		s+=x%10;
		x/=10;
	}
	return s;
}

int main (){
 ios_base
 cin >> n;
 int mn = inf;
 for(int i = 1; i <= n / 2; i ++){
 	mn = min(mn,f(i)+f(n-i));
	}
	cout << mn;
	return 0;
}

