# coding=utf-8: import re s = str(input()) c = re.compile(r'.*?c.*?w.*?w') if "cww" in s: print(3) elif re.search(c, s) == None: print(-1) elif len(s) >= 4: countList = list() for i in range(len(s)): temp1 = re.search(c, s[i:]) if temp1 != None: temp2 = temp1.group() countList.append(len(temp2)) else: break print(min(countList))