The problem is a straight forward implementation problem with strings. Anyone going with INT or LONG LONG INT will get wrong answer.
To get the problem right you need two things to do. Suppose you are on the "i"th digit of the input string then:
The catch with the problem is that you will get a TLE if not optimized. Say, wrongly handled in vector or NOT BREAKing INSTANTLY when x>9.