integer::i,c1,c2,w,mincww
  character*100::S
  data c1,c2,w,mincww/0,0,0,101/
  read *,S
  do i=1,LEN_TRIM(S)
     if(S(i:i).eq.'c') then
        if(w.eq.0) then
           c1 = i
        else
           c2 = i
        end if
     else if (S(i:i).eq.'w') then
        if (c1.eq.0) cycle
        if (w.ne.0) then
           mincww = MIN(mincww, i-c1+1)
           if (c2.ne.0) then
              c1 = c2
              c2 = 0
              w  = i
           else
              c1 = 0
              w  = 0
           end if
        else
           w = i
        end if
     end if
  end do
  if (mincww.eq.101) then
     print '(a)',"-1"
  else
     print '(i0)',mincww
  end if
end program