#!/usr/bin/env python3 #fileencoding: utf-8 count = 0 mi = 100 w_2 = False cww = False for i in input(): if i == "c": count = 1 elif count >= 1 and i == "w" and w_2 == False: count += 1 w_2 = True elif w_2 and i == "w": cww = True count += 1 if mi > count: mi = count count = 0 else: if count >= 1: count += 1 else: count = 0 print(mi if cww else -1)