{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"PLAIN","content":"Bilbo Baggins is a hobbit helping out the dwarfs to find their lost treasures in Lord of the Rings.\nAs they are hobbits and dwarfs , they can live for thousand years . To find the lost treasures and to get back the kingdom of dwarfs from Smaug(the dragon) they need to pass through the secret door.\n\n\nBut the secret door only opens in some special years. If the digits of the year are distinct (different from each other ), only then the door opens. They need at least one year to travel to that misty mountain. So, if even they start at 1987 , the door would open on 2013. Meanwhile, they have to wait at Rivendell and take other preparations.But the dwarfs are too dumb to find out the special year. Help Bilbo to find out the year when the door would open next so that they can work accordingly."}},{"title":"Input","value":{"format":"PLAIN","content":"The single line contains integer P(1000\u003c\u003dP\u003c\u003d9000) , the year they started the journey ."}},{"title":"Output","value":{"format":"PLAIN","content":"Print a single integer — the next year for opening the door again that is strictly larger than P and all it\u0027s digits are distinct. It is guaranteed that the answer exists."}},{"title":"Example 01","value":{"format":"PLAIN","content":" Input\n\n 1987\n\n Output\n\n 2013\n\n"}},{"title":"Example 02","value":{"format":"PLAIN","content":" Input\n \n2013\n\nOutput\n\n2014"}},{"title":"Caution","value":{"format":"PLAIN","content":"Read the problem carefully and share the code :) "}}]}