Count the number of filtered characters and character frequencies of a string in python