# use strict; # use warnings; chomp(my $S = <>); my @r; while ($S =~ /c.*?w.*?w/g) { push(@r, length(substr($S, $-[0], $+[0] - $-[0]))); } print(scalar(@r) ? (sort({$a <=> $b} @r))[0] : -1, "\n");