// music - INF
#include <bits/stdc++.h>
 
 
#define F first
#define S second 
#define int long long
#define farth(i, s) for (__typeof (s.begin ()) i = s.begin (); i != s.end (); ++i)
 
#define make make_pair
#define rall(x) x.rbegin (), x.rend () 
#define read scanf
#define print printf
 
#define bp pop_back
#define pb push_back
#define sz(x) (int)(x.size())
 
#define pf push_front
#define bit __builtin_popcount
#define lower(a, n, x) lower_bound (a + 1, a + 1 + n , x) - a 
#define upper(a, n, x) upper_bound (a + 1, a + 1 + n , x) - a 
 
#define sqr(x) ((x) * 1ll * (x))
#define FAST cin.tie(0); cout.tie(0);
#define all(x) x.begin (), x.end ()
 
#define TIME clock () * 1.0 / CLOCKS_PER_SEC
#define lcm (n, m) (((a) * 1ll * (b)) / __gcd (n, m))
#define CLOCK clock () / (double)CLOCKS_PER_SEC
#define MAGARADZHA ios_base::sync_with_stdio(false);
 
using namespace std;
 
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef pair < ll, pair < ll, ll > > plll;
typedef vector < pair < ll, ll > > vpll;
                                                                 
typedef pair < pair < ll, ll >, pair < ll, ll > > pllll;
typedef vector < ll > vl;
typedef vector < string > vs;
typedef vector < vector <ll > > matrix;
 
typedef pair < ll, ll > pll;
typedef map <ll, ll> mll;
typedef set <ll> sl;
typedef set < pair < ll, ll > > spll;
 
const int MOD = (int)1e9 + 7;
const int N = (int)1e6;                                
const int M = (int)1e3 * 3;
const ll INF = (ll)1e18;
const int NBA = (int)1e6 * 4;                                                                        
const double eps = (double)1e-9;
const int inf = (int)1e9 + 338;

int n;
main () {
	MAGARADZHA
	FAST
	cin >> n;
	int mx = INF;
	for (int i = 1; i <= n; ++i) {
		int l = n - i;
		int r = i;
		if(l == 0 || r == 0)continue;
		int sum = 0;
		while(l) {
			sum += l % 10;
			l /= 10;
		}
		while(r) {
			sum += r % 10;
			r /= 10;
		}
		mx = min(mx, sum);
	}
	cout << mx;
	return 0;
}