s = input() cww = float('inf') for i in range(len(s)): for j in range(i+1, len(s)): for k in range(j+1, len(s)): if s[i] == "c" and s[j] == "w" and s[k] == "w": cww = min(cww, k - i + 1) if cww == float('inf'): print(-1) else: print(cww)