my $str = prompt;
my %char_count = $str.comb.Bag;
my @char_count_sorted = %char_count.sort(*.value).reverse;
say "String: $str";
say '';
say 'Character occurence (most frequent to least frequent):';
for @char_count_sorted -> $pair {
my $char = $pair.key;
my $count = $pair.value;
my $display_char = $char eq ' ' ?? '<space>' !! $char;
say "$display_char: $count";
}