Problem:
Score : 200 points

Problem Statement

Takahashi has two positive integers A and B.

It is known that A plus B equals N.
Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).

Constraints

2 ≤ N ≤ 10^5

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B".

Sample Input 1

15

Sample Output 1

6

When A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.

Sample Input 2

100000

Sample Output 2

10

Solution in Pascal (FPC 2.6.2) (judge verdict: Runtime Error)

  var  f,g:text; i1,t,i,p:longint; n,a,b,k,tong,so,tong1,tong2:int64;
      gt,rev,rev1:array[0..300010] of int64;


 function mu(a1,b1,p1:int64):int64;
 var q:int64;
 begin
   if b1=1 then exit(a1);
   if b1=0 then exit(1);
   q:=mu(a1,b1 div 2,p1);
   if b1 mod 2 = 0 then exit(q*q mod p1)
    else exit((((q*q) mod p1) *a1 mod p1) mod p1);
 end;

 begin

  gt[0]:=1;
  p:=998244353; rev[0]:=1;
  for i:=1 to 300005 do
  begin
   gt[i]:=(gt[i-1] mod p * i mod p ) mod p;
  end;
  for i:=0 to 300005 do
   begin
    rev[i]:=mu(gt[i],p-2,p);
    end;

// write(g,((gt[n]* (rev[i] mod p)) mod p * (rev[n-i] mod p)) mod p ,' ');

  readln(n,a,b,k);

  tong:=0;
  for i:=0 to n do
   begin
    if (k-i*A)<0 then break;
    if (k-i*A) mod b = 0 then
     begin
     so:=(k-i*A) div B;
     tong1:=((((gt[n]* rev[i] ) mod p )* (rev[n-i] mod p)) mod p);
     tong2:=((((gt[n]* rev[so]) mod p) * (rev[n-so] mod p)) mod p);
     tong:=tong+tong1*tong2;
     end;
   end;
  write(tong);

  end.