a=input() b=0 g=-1 for i,j in enumerate(a): if j=="c": g=i if (j=="w") and (g!=-1): b+=i if b!=i: print(i-g+1) break else: print("-1")