package me.yukicoder.lv1; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class No0345 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String str = br.readLine(); int ans = -1; int idx = str.indexOf("c"); if (idx != -1) { String str1 = str.substring(idx, str.lastIndexOf("w") + 1); Matcher m = Pattern.compile("c.*w.*w").matcher(str1); ans = m.matches() ? m.end() : ans; } System.out.println(ans); } catch (IOException e) { e.printStackTrace(); } } }