V (vim), 7 bytes
Ó± Ø^$ Try it online! or Verify test cases
Hexdump:
00000000: d388 b10a d85e 24 .....^$ Just two regexes. Explanation:
Ó " Remove all occurrences... ˆ " Any character ± " Followed by itself " This regex is actually just the compressed form of (.)\1 Ø " Count the number of matches ^$ " An empty line