#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re def solve(s): pattern = re.compile(r"c.*?w.*?w") matches = re.findall(pattern, s) if not matches: return -1 else: cands = [match.strip("c") for match in matches] return min(map(len, cands)) + 1 if __name__ == '__main__': print(solve(input()))