# coding=utf-8: import re s = str(input()) if "cww" in s: print(3) elif "cww" not in s: print(-1) elif len(s) < 3: print(-1) elif len(s) >= 4: c = re.compile(r'.*c.*w.*w') 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))