S = input() ans = 101 for i in range(0,len(S)-2): for j in range(i+2,len(S)): if S[i] == "c" and S[j] == "w" and S[i:j+1].count("w") == 2: ans = min(ans,j-i+1) else: continue if ans == 101: print(-1) else: print(ans)