#!/usr/bin/env python3 #fileencoding: utf-8 count = 0 mi = 100 w_cnt = 0 for i in input()[::-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 if cww else -1)