#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<iomanip>
#include<stdio.h>
#include<math.h>
#include<string>
#include<unordered_map>
//#include <bits/stdc++.h>

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back
#define ll long long
#define ull unsigned long long

#define FOR(i,j,k) for(ll i=j;i<k;i++)
#define REV(i,j,k) for(ll i=j;i>k;i--)
#define mnn (long long) -1000000000000000
#define mxn (long long) 1000000000000000
#define pi 2.0*acos(0.0)
#define INF 1e18

#define all(x) x.begin(),x.end()

#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x)
#define sdd(x,y) scanf("%lf%lf",&x,&y)
#define sddd(x,y,z) scanf("%lf%lf%lf",&x,&y,&z)
#define ss(str) scanf("%s",str)

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);


#define pq priority_queue<double>
using namespace std;


/// Binary Segment

/*

ll _LeftIP_BinarySearch(ll st,ll nd,ll key,ll *_Arr)
{
    if(st>nd) return st;
    ll md= (st+nd)>>1 ;
    if(_Arr[md]>=key) return _LeftIP_BinarySearch(st,md-1,key,_Arr);
    else return _LeftIP_BinarySearch(md+1,nd,key,_Arr);

}

ll _RightIP_BinarySearch(ll st,ll nd,ll key,ll *_Arr)
{
    if(st>nd) return st;
    ll md= (st+nd)>>1 ;
    if(_Arr[md]>key) return _RightIP_BinarySearch(st,md-1,key,_Arr);
    else return _RightIP_BinarySearch(md+1,nd,key,_Arr);
}

ll _CountByBinarySearch(ll st,ll nd, ll key,ll *_Arr)
{
    if(st>nd) return 0;
    ll md= (st+nd)>>1 ;
    if(_Arr[md]>key) return _CountByBinarySearch(st,md-1,key,_Arr);
    else if (_Arr[md]<key)  return _CountByBinarySearch(md+1,nd,key,_Arr);
    else return 1 + _CountByBinarySearch(st,md-1,key,_Arr)+ _CountByBinarySearch(md+1,nd,key,_Arr);
}

ll _BinarySearch(ll st,ll nd,ll key,ll *_Arr)
{
    if(st>nd) return 0;
    ll md= (st+nd)>>1 ;
    if(_Arr[md]>key) return _BinarySearch(st,md-1,key,_Arr);
    else if (_Arr[md]<key)  return _BinarySearch(md+1,nd,key,_Arr);
    return md;
}

*/


/// Number

/*
bool _Primes[1000005];
void _GeneratePrimes()
{
    ll lim=sqrt(1000004);
    for(ll i=4;i<=1000004;i+=2) _Primes[i]=true;
    _Primes[1]=true; _Primes[0]=true;
    for(ll i=3;i<=lim+1;i+=2)
    {
        if(!_Primes[i]) for(ll j = i*i; j<=1000000;j+=i) _Primes[j]=true;
    }
}
*/

/// Graph

struct Node{
    ll val;
    Node *next;
};
 Node *Root=NULL;

 void _addNodeEnd(ll n)
 {
     if(Root==NULL)
     {
         Root=new Node();
         Root->next=NULL;
         Root->val=n;
     }
     else
     {
         Node *curNode=Root;
         while(curNode!=NULL) curNode=curNode->next;
         Node *newNode=new Node();
         newNode->next=NULL;
         newNode->val=n;
         curNode->next=newNode;
     }
 }

/// Geometry

struct Point{
    ll x;
    ll y;
};
bool _Asc_compare(Point lhs, Point rhs) { return lhs.x < rhs.x; }
bool _Desc_compare(Point lhs, Point rhs) { return lhs.x > rhs.x; }

///Hash

ll _unique(ll x,ll y)
{
    return (x+(y*100000));
}
ll gcd(ll x,ll y )
{
    if(y==0) return x;
    return gcd(y,x%y);
}
ll a,b,c,d,e,f,g,h;
ll pls=1,mns;
string st;
char ch,dh;
char arr[1000];
ll sum_of_digit(ll n)
{
    if (n == 0)
       return 0;
    return (n % 10 + sum_of_digit(n / 10));
}
int main()
{
    b=mxn;
   cin>>a;
   FOR(i,1,a)
   {
       b=min(sum_of_digit(i)+sum_of_digit(a-i),b);
   }
   cout<<b;
}



Measured memory_bytes: 256