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 \leq a, b \leq 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 \leq n \leq 10^{12})$.


-----Output-----

Print largest $S(a) + S(b)$ among all pairs of integers $a, b$, such that $0 \leq a, b \leq 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.

Difficulty: competition

Starter code:

Solutions:
n = int(input())

a = int(str(n)[0])
l = len(str(n)) - 1

val1 = a * 10 ** l - 1
val2 = n - val1

def sd(x):
    return sum(int(d) for d in str(x))

print(sd(val1) + sd(val2))


n = int(input())
a = [0]

for i in range(13):
	for j in range(1, 10):
		a += [int(str(j) + i * '9')]

mx = 0

for i in a:
	if i <= n:
		mx = max(mx, sum(map(int, str(i))) + sum(map(int, str(n-i))))

print(mx)

#!/usr/bin/env python3
def s(x):
    return sum(map(int, str(x)))
n = int(input())
ans = 0
a = 0
while a <= n:
    b = n - a
    ans = max(ans, s(a) + s(b))
    a = 10 * a + 9
print(ans)


def s(x):
	res = 0
	while x > 0:
		res += x % 10
		x //= 10
	return res

n = input()
ans = 9*(len(n)-1)
n = int(n) - 10**(len(n) - 1) + 1
print(ans + s(n))

def mainA():
    n = int(input())
    s = input()
    cnt = 0
    for i in s:
        if i == '8':
            cnt += 1
    print(min(cnt, n // 11))

def mainB():
    def get(n):
        ret = 0
        while n > 0:
            ret += n % 10
            n //= 10
        return ret
    
    n = int(input())
    if n <= 9:
        print(n)
        return
    t = 9
    while n > t:
        t = t * 10 + 9
    t //= 10
    print(get(t) + get(n - t))

mainB()

n = int(input())
sa = "0"

def comp(k):
    a = int(k)
    b = n - a
    return b

while comp(sa) >= 0:
    if comp(sa + "9") >= 0:
        sa += "9"
    else:
        break

print(sum(int(h) for h in (sa + str(comp(sa)))))


from math import log10, ceil

def sumdigs(n):
    return sum(map(int, str(n)))
n = int(input())
tens = int(log10(n))
nines = tens * 9
print(nines + sumdigs(n - ((10 ** tens) - 1)))


s = input()
su = sum(map(int, list(s)))

while (len(s) > 0 and s[-1] == '9'):
    s = s[:-1]
print(su + 9 * max(0, len(s) - 1))

def sum(x):
    res = 0
    while x:
        res += x % 10
        x //= 10
    return res

n = int(input())
ans = 0
for i in range(min(n, 1000)):
    ans = max(ans, sum(i) + sum(n - i))
for i in range(1, 13):
    nine = '9' * i
    for j in range(10):
        tmp = int(str(j) + nine)
        if tmp <= n:
            ans = max(ans, sum(tmp) + sum(n - tmp))
print(ans)


n = int(input())

def get(a):
    return sum(map(int, str(a)))

def solve(n):
    cnt = len(str(n))
    if cnt == 1:
        return get(n)
    ret = get(n)
    for a in ['9' * (cnt - 1)]:
        ret = max(get(int(a)) + get(n - int(a)), ret)
    return ret
    
print(solve(n))



a=int(input())
c=0
while a>0:
    if a%10<9 and a>9:t=10+a%10
    else:t=a%10
    c+=t
    a-=t
    a//=10
print(c)

n=input()
if int(n) < 10:
    print(n)
else:
    sa = "9" * (len(n) - 1)
    b = int(n) - int(sa)
    sb = str(b)
    sum = 0
    for i in sa:
        sum += int(i)
    for i in sb:
        sum += int(i)
    print(sum)


n = int(input())
t = len(str(n))
if t==1:
  x = 0
else:
  x = int((t-1)*'9')
y = n - x
def sm(x):
  res = 0
  for i in str(x):
    res+=int(i)
  return res
print(sm(x)+sm(y))

def d(x):
    c = 0
    while x > 0:
        c += x%10
        x //= 10
    return c
n = int(input())
ans = 0
if n <= 10:
    ans = n
else:
    temp = 9
    while temp*10+9 < n:
        temp *= 10
        temp += 9
    b = n - temp
    ans += d(b)
    ans += d(temp)
print(ans)

n=int(input())
a=n
c=0
while a>=10:
    a//=10
    c+=1
b=(a)*(10**c)-1
a=n-b
c=0
while a!=0:
    c+=a%10
    a//=10
a=b
while a!=0:
    c+=a%10
    a//=10
print(c)


n = input()

if len(n) == 1:
    print(n)
else:
    if len([_ for _ in n if _ != '9']) == 0:
        a, b = n, '0'
    else:
        a = '9' * (len(n) - 1)
        b = str(int(n) - int(a))

    s = sum([int(_) for _ in a]) + sum([int(_) for _ in b])
    print(s)


n=input()
def su(n):
    s=0
    for i in str(n):
        s+=int(i)
    return s
    
if int('9'*len(n))<=int(n):
    print(9*len(n)+su(-int('9'*len(n))+int(n)))
else:
    if len(n)>1:
        print(9*(len(n)-1)+su(-int('9'*(len(n)-1))+int(n)))
    else:
        print(n)


n=int(input())
s=0
m=0
while(m<=n):
	s=s+9
	m=m*10+9
y1=n-(m//10)
s=s-9
y=str(y1)
for i in y:
	s=s+int(i)
print (s)


#1000=999+1
#1000=499+501

#35=9+26

n=input()
x=len(n)

if x>=2:
    m1=int("9"*(x-1))
else:
    m1=0
m2=int(n)-m1

ANS=0
for i in str(m1)+str(m2):
    ANS+=int(i)

print(ANS)


from sys import stdin, stdout 
from bisect import bisect_left, bisect_right
from collections import defaultdict
import math
from fractions import Fraction as frac
from random import random
cin = stdin.readline
def cout(x):
	stdout.write(str(x)+'\n')
def var(type = int):
    return type(stdin.readline())
def readline(type = int):
    return map(type,stdin.readline().split())
def readlist(type = int):
    return list(map(type,stdin.readline().split()))
def sorted_indexes(arr):
    return sorted(range(len(arr)),key=arr.__getitem__)
def printr(arr):
    [stdout.write(str(x)+' ')   for x in arr]
    cout('')
def find_lt(a, x):#'Find rightmost value less than x'
    i = bisect_left(a, x)
    if i:
        return a[i-1]
    raise ValueError
def find_gt(a, x):#'Find leftmost value greater than x'
    i = bisect_right(a, x)
    if i != len(a):
        return a[i]
    raise ValueError
def dist(x,y):
    return math.sqrt(x*x + y*y)
def binary_search(arr, x):
    i = bisect_left(arr, x)
    if i == len(arr) or arr[i] != x:
        return -1
    return i
MOD2 = 998244353

#----------------FUncs

def sm(x):
    x = str(x)
    s = 0
    for n in x:
        s += int(n)
    return s


# -------------------------sdpt,sdpt131[Sudipta Banik]---------------------

n = int(input())
a = 0
a_prev = 0
while a <= n:
    a_prev = a
    a = a*10 + 9
a = a_prev
print(sm(n-a)+sm(a))    

def digsum(n):
    return sum(map(int, str(n)))

A = int(input())
n = A // 2
s = str(n)
s = s[0] + '9' * len(s[1:])
print(digsum(int(s)) + digsum(A-int(s)))

n = int(input())
if n < 10:
	print(n)
	return
a = n - int(str(n)[1:]) - 1
b = n - a
a = [*map(int, str(a))]
b = [*map(int, str(b))]
print(sum(a) + sum(b))

import math

n = int(input())

def S(n):
    return sum(map(int,list(str(n))))

base = 10**int(math.log10(n))
a = base-1
res = 0
for i in range(10):
    b = n-a
    res = max(res, S(a)+S(b))
    a+=base
    if a > n:
        break
print(res)


n = input()
if len(n) == 1:
    print(int(n))
else:
    a = ""
    if n[0] != '1':
        a += chr(ord(n[0]) - 1)
    a += '9' * (len(n) - 1)
    b = str(int(n) - int(a))
    print(sum(map(int, list(a) + list(b))))


"""n=int(input())
s=input()
c=0
for i in range(0,len(s)):
    if(s[i]=='8'):
        c=c+1
k=len(s)//11
print(min(c,k))"""


n=int(input())
N=str(n)
if(len(N)==1):
    print(n)
else:
    l=len(N)-1
    k=int('9'*l)
    diff=n-k
    D=str(diff)
    K=str(k)
    sumu=0
    for i in range(0,len(D)):
        sumu=sumu+int(D[i])
    for i in range(0,len(K)):
        sumu=sumu+int(K[i])
    print(sumu)