count repetitive string from the back