s = raw_input() l = [] for i in range(len(s)): if s[i] == 'c': w = 0 for j in range(i+1,len(s)): if s[j] == 'w': w += 1 if w == 2: l.append(j-i+1) break if l == []: print -1 else: print min(l)