Python Counting Elements Leetcode