#coding:utf-8 str=raw_input() cww=str[str.index('c'):] c_w=list(cww[:cww.index('w')+1]) s=[] for i in cww[cww.index('w')+1:]: if 'w' not in i: s.append(i) else: s.append('w') break if not c_w or not s or 'w' not in s: print -1 else: print len(c_w + s)