Verify the input string to do the algorithm