/* Nurgazy Zhandos */

#include <bits/stdc++.h>

#define F first
#define S second

#define pf push_front
#define pb push_back
#define mp make_pair
#define pp pop_back
#define in insert

#define up upper_bound
#define lb lower_bound

#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define sz(a) a.size()

#define nl '\n'

//#define int long long

using namespace std;

typedef pair <long long, long long> pll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long double ld;
typedef long long ll;

const int MAX_N = 1e5 + 123;
const int inf = 1e9 + 123;
const ll INF = 1e18 + 123;
const int NN = 2e6 + 123;
const double eps = 1e-9;
const int mod = 1e9 + 7;

/*void random() {
 		unsigned int FOR;
 		asm("rdtsc" : "=A" (FOR));
	srand(FOR);
}*/

inline void fre() {
	#ifdef TEZZY
//	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
	#endif
}

inline void boost() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
}

int rep(int n) {
 	int cnt  =0;

 	while(n) {
 	 	cnt += n % 10;
 	 	n /= 10;
 	}

 	return cnt;
}

main () {
	fre();
	boost();

	int n;
	cin >> n;

	int mn = inf;

	for(int i = 1; i <= n / 2 + 1; i++) {
		mn = min(mn, rep(i) + rep(n - i));
	}
	
	cout << mn;
}