Solution to character frequency