import re;print(len(s[0])if(s:=re.search("c[^cw]*?w[^wc]*?w",input()))else-1)