use v6; my @str = get().chomp.split(''); my $w = 0; my $long = 0; loop (my $i = 1; $i < @str.elems - 1; $i++) { if @str[$i] eq 'c' { loop (my $j = $i; $j < @str.elems - 1; $j++) { if @str[$j] eq 'w' { if $w == 0 { $w++; } elsif $w == 1 { if $long == 0 { $long = $j - $i + 1; } elsif $j - $i + 1 < $long { $long = $j - $i + 1; } $w = 0; last; } } } } } if $long == 0 { say -1; } else { say $long; } exit;