import sys S = str(input()) result = sys.maxsize for i, s in enumerate(S): if s == 'c': _f = S[i + 1:].find('w') _s = S[i + _f + 2:].find('w') if _f >= 0 and _s >= 0 and result > (_f + _s + 3): result = (_f + _s + 3) print(result if result != sys.maxsize else - 1)