import sys from collections import Counter sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): s=input() pos_c=101 pos_w=-2 ans=[] for i,c in enumerate(s): if c=="c": pos_c=i if c=="w": if pos_w>pos_c: ans.append(i-pos_c+1) pos_w=-2 else: pos_w=i if ans:print(min(ans)) else:print(-1) main()