read s s=c$s while echo $s | grep -q c; do s=$(echo $s | sed s/^[^c]*c//) expr $(echo $s | sed -nE 's/[^c]*(c[^w]*w[^w]*w).*/\1/p' | wc -c) - 1 done | sort -nr | head -1