s=input()
k=len(s)
print(10*k-9+int(s[0])-(s[0]*k>s)-(k>1))
