Counting geometric figures