Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t = int(input())
- for i in range(t):
- x = input()
- if int(x) < 10:
- print(x)
- else:
- y = len(x)
- z = x[0]*y
- if int(x) >= int(z):
- ans = 9*(y-1)+int(x[0])
- else:
- ans = 9*(y-1)+int(x[0])-1
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement