# -*- coding: utf-8 -*- import re S = raw_input() result = re.search("c[^c]*?w.*?w", S) if result: print len(result.group()) else: print -1