#!/bin/bash read s c=`echo $s | awk '{match($0,/c+/); print substr($0, RSTART, RLENGTH);}'` w=`echo $s | awk '{match($0,/w+/); print substr($0, RSTART, RLENGTH);}'` if [ `expr ${#c} - 1` -le ${#w} ]; then echo `expr ${#c} - 1` else echo ${#w} fi