#!/usr/bin/env python3 #fileencoding: utf-8 count = 0 mi = 100 w_cnt = 0 start = 0 mi_start = 0 mi_end = 0 cww = False S = input() for idx,i in enumerate(S): if count == 0 and i == "c": count += 1 start = idx elif count >= 1 and i == "w": w_cnt += 1 count += 1 if w_cnt >= 2: cww = True if mi > count: mi = count mi_start = start mi_end = idx+1 count = 0 w_cnt = 0 else: if count >= 1: count += 1 else: count = 0 if cww is False: print(-1) else: s = S[mi_start:mi_end] count = 0 w_cnt = 0 for i in s[::-1]: if i == "w": count += 1 w_cnt += 1 elif w_cnt >= 2 and i == "c": cww = True count += 1 if mi > count: mi = count count = 0 w_cnt = 0 else: if count >= 1: count += 1 else: count = 0 print(mi)