def cfind(s): w1 = s.find('w') w2 = s[(w1 + 1):].find('w') if w1 != -1 and w2 != -1: cww = w1 + w2 + 3 else: cww = 101 if s.find('c') == -1: return cww return min(cww, cfind(s[(s.find('c') + 1):])) S = input() ans = cfind(S[(S.find('c') + 1):]) print(ans) if ans != 101 else print(-1)