public class CodeCount {
    /**
     * Return the number of times that the string "code" appears anywhere in the given string,
     * except we'll accept any letter for the 'd', so "cope" and "cooe" count.
     * <p>
     * Examples:
     * countCode("aaacodebbb") → 1
     * countCode("codexxcode") → 2
     * countCode("cozexxcope") → 2
     */
    public static int countCode(String str) {
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if ((str.charAt(i) == 'c') &&
                    (str.charAt(i + 1) == 'o') && (str.charAt(i + 3) == 'e')) {
                count += 1;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        StdOut.println(countCode(args[0]));
    }
}
