Consider an input string of "abc"
- Line 9 reads 'a' into input
- Line 13 reads 'b' into input
- Next time through the loop, Line 13 reads 'c' into input.
The points is that the first character isn't added to letterCounts.
Try getting rid of line 9 and change line 11 to while ((cin << input) && input != '!')
Also, you need to skip characters that aren't letters. You're making a call to isalpha() which will tell you if the character is a letter, but you don't do anything with that knowledge.