How to count the number of letters and add an incremental value to it?