let input = require('fs').readFileSync('/dev/stdin', 'utf8'); let ans = [input.match(/c[^c]*?w.*?w/g)[0], input.match(/c[^c]*?w[^c]*?w/g)[0]]; ans = ans.filter(v => v); console.log(ans.length ? Math.min(...ans.map(v => v.length)) : -1);