Ada and Math

0

0 votes
Problem

Ada is poor in math, but now she wants to join Now or Never for learning. In the interview she was given a problem for her to solve but she couldn't solve it. Since there is time for her results, so she wants help from you.She will be given a positive integer P. A function F(x)is defined such that it always gives sum of digits of x.  For example F(341)=3+4+1=8,F(0)=0.You have to find two integers u,v, such that 0<=u,v<=P and u+v=P and also  is largest possible among all such pairs.

 


CONSTRAINTS:

1<=P<=1012

0<=u,v<=P

u+v=P

INPUT:  The only line of input contains an integer P

OUTPUT:   Print largest F(u)+F(v) among all pairs of integers u,v

Example:    

1) Input- 35

   Output-17

2) Input-10000000000

    Output:91

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?