# -*- coding: utf-8 -*- S = raw_input() Slist = list(S) N = len(Slist) lencww = str("inf") flag = 0 c = -1 for i in range(0,N): if Slist[i] == "c": c = i if flag % 2 == 0 and 0 <= c < i and Slist[i] == "w": flag += 1 elif flag % 2 == 1 and 0 <= c < i and Slist[i] == "w": flag += 1 tmp = i - c + 1 if tmp < lencww: lencww = tmp if 1 < flag: print lencww else: print -1