S = input() ans = 101 for i in range(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 print(ans if ans != 101 else -1)