# -*- coding: utf-8 -*- S = input() l = -1 min_l = 101 state = 0 # 0:c探索中, 1:cセット中, 2:最後のw探索中 for c in S: l += 1 if c == 'c' and state == 0: l = 1 state = 1 elif c == 'w' and state == 1: state = 2 elif c == 'w' and state == 2: state = 0 min_l = min(min_l, l) min_l = -1 if min_l==101 else min_l print(min_l)