my $a = words.Bag; if $a.values.sort eq (2, 2, 3, 3, 3) { say 2; put $a.grep(*.value == 2)>>.key.sort; } elsif $a.values.sort eq [1, 3, 3, 3, 3] { say 1; put $a.grep(*.value == 1)>>.key; } else { say 0; put []; }