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:
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class TaskB
{
    public static void main(String[] args)
    {
        new TaskB(System.in, System.out);
    }

    private static class Solver implements Runnable
    {
        long n;
        // BufferedReader in;
        InputReader in;
        PrintWriter out;

        void solve() throws IOException
        {
//            brute();

            long temp = n = in.nextLong();

            if (n < 9)
            {
                out.println(n);

                return;
            }

            long a = 9;
            long b = 0;
            long mul = 1;

            while (a <= n)
            {
                a *= 10;
                a += 9;
            }

            a /= 10;
            n -= a;

            for (int i = 0; i < 10; i++)
            {
                long x = Long.parseLong("" + i + "" + a);

                if (x <= temp)
                    a = x;
            }

//            System.out.println("a : " + a + ", b : " + b);
            out.println(s(a) + s(temp - a));

/*            if (n < 9)
            {
                out.println(s(a) + s(n));

                return;
            }

            b = 9;

            while (b <= n)
            {
                b *= 10;
                b += 9;
            }

            b /= 10;
            n -= b;

            b *= 10;
            b += n;

            out.println(s(a) + s(b));*/
        }

        void brute()
        {
            n = 207;

            int max = 0;

            for (int i = 0; i <= n; i++)
            {
                int a = i;
                int b = (int) (n - a);

                System.out.println("a : " + a + ", b : " + b + ", ans : " + (s(a) + s(b)));
                max = Math.max(max, s(a) + s(b));
            }

            out.println(max);
        }

        int s(long x)
        {
            String str = "" + x;
            int sum = 0;

            for (char ch : str.toCharArray())
                sum += (ch - '0');

            return sum;
        }

        // uncomment below line to change to BufferedReader
        // public Solver(BufferedReader in, PrintWriter out)
        Solver(InputReader in, PrintWriter out)
        {
            this.in = in;
            this.out = out;
        }

        @Override
        public void run()
        {
            try
            {
                solve();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        int nextInt()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        int[] nextIntArray(int arraySize)
        {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++)
                array[i] = nextInt();

            return array;
        }

        long nextLong()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sign = 1;

            if (c == '-')
            {
                sign = -1;

                c = read();
            }

            long result = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                result *= 10;
                result += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return result * sign;
        }

        long[] nextLongArray(int arraySize)
        {
            long array[] = new long[arraySize];

            for (int i = 0; i < arraySize; i++)
                array[i] = nextLong();

            return array;
        }

        float nextFloat()
        {
            float result, div;
            byte c;

            result = 0;
            div = 1;
            c = (byte) read();

            while (c <= ' ')
                c = (byte) read();

            boolean isNegative = (c == '-');

            if (isNegative)
                c = (byte) read();

            do
            {
                result = result * 10 + c - '0';
            } while ((c = (byte) read()) >= '0' && c <= '9');

            if (c == '.')
                while ((c = (byte) read()) >= '0' && c <= '9')
                    result += (c - '0') / (div *= 10);

            if (isNegative)
                return -result;

            return result;
        }

        double nextDouble()
        {
            double ret = 0, div = 1;
            byte c = (byte) read();

            while (c <= ' ')
                c = (byte) read();

            boolean neg = (c == '-');

            if (neg)
                c = (byte) read();

            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = (byte) read()) >= '0' && c <= '9');

            if (c == '.')
                while ((c = (byte) read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);

            if (neg)
                return -ret;

            return ret;
        }

        String next()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do
            {
                res.appendCodePoint(c);

                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        String nextLine()
        {
            int c = read();

            StringBuilder result = new StringBuilder();

            do
            {
                result.appendCodePoint(c);

                c = read();
            } while (!isNewLine(c));

            return result.toString();
        }

        boolean isNewLine(int c)
        {
            return c == '\n';
        }

        void close()
        {
            try
            {
                stream.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }

        InputReader(InputStream stream)
        {
            this.stream = stream;
        }

    }

    private static class CMath
    {
        static long power(long number, long power)
        {
            if (number == 1 || number == 0 || power == 0)
                return 1;

            if (power == 1)
                return number;

            if (power % 2 == 0)
                return power(number * number, power / 2);
            else
                return power(number * number, power / 2) * number;
        }

        static long modPower(long number, long power, long mod)
        {
            if (number == 1 || number == 0 || power == 0)
                return 1;

            number = mod(number, mod);

            if (power == 1)
                return number;

            long square = mod(number * number, mod);

            if (power % 2 == 0)
                return modPower(square, power / 2, mod);
            else
                return mod(modPower(square, power / 2, mod) * number, mod);
        }

        static long moduloInverse(long number, long mod)
        {
            return modPower(number, mod - 2, mod);
        }

        static long mod(long number, long mod)
        {
            return number - (number / mod) * mod;
        }

        static int gcd(int a, int b)
        {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

        static long min(long... arr)
        {
            long min = arr[0];

            for (int i = 1; i < arr.length; i++)
                min = Math.min(min, arr[i]);

            return min;
        }

        static long max(long... arr)
        {
            long max = arr[0];

            for (int i = 1; i < arr.length; i++)
                max = Math.max(max, arr[i]);

            return max;
        }

        static int min(int... arr)
        {
            int min = arr[0];

            for (int i = 1; i < arr.length; i++)
                min = Math.min(min, arr[i]);

            return min;
        }

        static int max(int... arr)
        {
            int max = arr[0];

            for (int i = 1; i < arr.length; i++)
                max = Math.max(max, arr[i]);

            return max;
        }

    }

    private static class Utils
    {
        static boolean nextPermutation(int[] arr)
        {
            for (int a = arr.length - 2; a >= 0; --a)
            {
                if (arr[a] < arr[a + 1])
                {
                    for (int b = arr.length - 1; ; --b)
                    {
                        if (arr[b] > arr[a])
                        {
                            int t = arr[a];

                            arr[a] = arr[b];
                            arr[b] = t;

                            for (++a, b = arr.length - 1; a < b; ++a, --b)
                            {
                                t = arr[a];
                                arr[a] = arr[b];
                                arr[b] = t;
                            }

                            return true;
                        }
                    }
                }
            }

            return false;
        }

    }

    private TaskB(InputStream inputStream, OutputStream outputStream)
    {
        // uncomment below line to change to BufferedReader
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(inputStream));
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Thread thread = new Thread(null, new Solver(in, out), "Solver", 1 << 27);

        try
        {
            thread.start();
            thread.join();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }

        in.close();
        out.flush();
        out.close();
    }

}