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