#!/usr/bin/python # -*- coding: utf-8 -*- str = raw_input() flag = 0 count = 0 for i in str: if i == "c" and flag == 0: flag = 1 count += 1 elif i == "w" and flag == 1: flag = 2 count += 1 elif i == "w" and flag == 2: count += 1 print count exit() elif i != "c" and i != "w" and flag > 0: count += 1 else: flag = 0 count = 0 print '-1'