# time = O(N) memory = O(N*M) my $count = map @$_, values %h;