s = input() res = 114 while "c" in s: cidx = s.find("c") widx = s.find("w", cidx+1) if widx < 0: break w2idx = s.find("w", widx+1) if w2idx > 0: res = min(res, w2idx - cidx + 1) s = s[cidx+1:] print(res if res != 114 else -1)