s = input() ans = 111 lst = list(s) lenth = len(lst) for index,item in enumerate(lst): if item == "c": c = index for index,item in enumerate(lst): if item == "w" and index > c: w = index for index,item in enumerate(lst): if item == "w" and index > w: ww = index if ww - c + 1 < ans: ans = ww - c + 1 if item == "w" and index > ww: www = index if ans == 111: ans = -1 print(ans)