Problem: You are given a positive integer n.

Let S(x) be sum of digits in base 10 representation of x, for example, S(123) = 1 + 2 + 3 = 6, S(0) = 0.

Your task is to find two integers a, b, such that 0 ≤ a, b ≤ n, a + b = n and S(a) + S(b) is the largest possible among all such pairs.

Input

The only line of input contains an integer n (1 ≤ n ≤ 10^{12}).

Output

Print largest S(a) + S(b) among all pairs of integers a, b, such that 0 ≤ a, b ≤ n and a + b = n.

Examples

Input

35


Output

17


Input

10000000000


Output

91

Note

In the first example, you can choose, for example, a = 17 and b = 18, so that S(17) + S(18) = 1 + 7 + 1 + 8 = 17. It can be shown that it is impossible to get a larger answer.

In the second test example, you can choose, for example, a = 5000000001 and b = 4999999999, with S(5000000001) + S(4999999999) = 91. It can be shown that it is impossible to get a larger answer.

Solution (in JAVA):

Solution:
//Complete this code or write your own from scratch
import java.util.*;
import java.io.*;
import java.math.*;

public class Solution{
    
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 25;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
 
        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }
        public String readLine() throws IOException 
        { 
            byte[] buf = new byte[1280000]; // line length 
            int cnt = 0, c; 
            while ((c = read()) != -1) 
            { 
                if (c == '\n') 
                    break; 
                buf[cnt++] = (byte) c; 
            } 
            return new String(buf, 0, cnt); 
        } 
        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');
 
            if (neg)
                return -ret;
            return ret;
        }
    }
    
    public static void main(String[] argh) throws Exception{
        // Reader br = new Reader();
        BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
        
        long n= Long.parseLong(br.readLine().trim());
        String s= n+"";
        int len= s.length();

        int i=0;
        String dif= "";
        int sum= 0;
        if(len == 1){
            System.out.println(n);
            
        }
        else{
            while(i<len-1){
                dif= dif+"9";
                sum+=9;
                i++;
            }
            
            int pos= 0;
            int max= Integer.MIN_VALUE;
            while(pos <= 9){
                if(pos == 0){
                    long diff= n - Long.parseLong(dif);
                    int sumdif= findSum(diff);
                    if(sum+sumdif > max) max= sum+sumdif;
                }
                else{
                    dif= pos+dif;
                    sum += pos;
                    if(Long.parseLong(dif) > n) break;
                    long diff= n - Long.parseLong(dif);
                    int sumdif= findSum(diff);
                    if(sum+sumdif > max) max= sum+sumdif;
                    dif= dif.substring(1);
                    sum -= pos;
                }
                pos++;
            }
            
            
            
            System.out.println(max);
        }
        
    }
    private static int findSum(long num){
        long sum= 0;
        while(num>0){
            long d= num%10;
            sum += d;
            num /= 10;
        }
        return (int)sum;
    }
}