sentence = input() N = len(sentence) second = False min = 101 for i in range(N): if sentence[i] == "c": count = 1 for j in range(N-i-1): count = count+1 if sentence[i+j+1] == "w": if second == True: if min > count: min = count break else: second = True second = False if min == 101: min = -1 print(min)