import re def solve(): S = input() p = re.compile('c[^c]*?w.*?w') ms = p.findall(S) if ms: ans = 114514 for m in ms: ans = min(ans, len(m)) print(ans) else: print(-1) if __name__ == '__main__': solve()