V (vim), 7 bytes
Ó± ø^$ Try it online! or Verify test casesVerify 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