Another way is to use regular expression and find sequence matching in given string and then performing addition operation.