Let us call a number a lucky number if all the digits in the number are odd.
Given a number \(N\) , Alice wonders what is the nearest lucky number to \(N\).
Find a number \(X\) such that \(abs(N-X)\) is minimum and \(X\) is a lucky number.
Input Format:
First line contains an integer \(N\)
Output Format:
Print an integer \(X\) such that \(abs(N-X)\) is minimum
Incase of multiple answers, print the smallest answer
Constraints:
\(1 \leq N \leq 10^{18}\)
Nearest Lucky Numbers to 6, with all digits odd are 5 and 7 with abs(6-5) = abs(6-7) = 1
But since 5 is the smallest answer, print 5
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor