#Pyth, <s>19</s> 17 bytes

    l@jG+UTrG1mCidT.:

takes a string. 


[Try it!](https://pyth.herokuapp.com/?code=l%40jG%2BUTrG1mCidT.%3A&input=%225698%22&test_suite=1&test_suite_input=%225698%22%0A%22564693%22%0A%22530923864209124521%22%0A%221111111%22%0A%225115643141276343%22%0A%2256789%22%0A%2294%22%0A%221%22&debug=0)