#最初にcを観測して、次に現れるwとその次に現れるwを観測するといい #何文字目かを知りたいので、リストにしてから何番目の要素かを出力すると良さそう #1.文字列のリスト化 #2.特定文字の観測と何番目かの出力 #3.要素の引き算 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)