#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input())\n"
"c=10**18\n"
"for a in range(1,n):\n"
"    b=n-a\n"
"    c=min(c,sum(map(int,str(a)))+sum(map(int,str(b))))\n"
"print(c)\n"
"\"";
  system(s);
  return 0;
}            