#CCBCHBON0000049. Đếm lỗi trước lệnh END (Count Errors Before END)

Đếm lỗi trước lệnh END (Count Errors Before END)

Count Errors Before END

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

A command stream contains E (error), O (ordinary) and X (END). Count E characters before the first X; X is not counted. The input contains no whitespace or trailing newline. Print 0 if X is the first character.

Input

A stream of 0..100000 E/O characters followed by exactly one final X, with no whitespace or newline.

Output

Print the number of E characters before X followed by LF.

Subtasks

  • Subtask 1 (20%): At most 10 E/O symbols before the final X.

  • Subtask 2 (30%): At most 1000 E/O symbols before the final X.

  • Subtask 3 (50%): At most 100000 E/O symbols before the final X.

Examples

Example 1

Input:

EOEEX

Output:

3

Explanation:

Count E before X; neither O nor X qualifies. Exact input: "EOEEX"; exact output: "3\n".

Example 2

Input:

X

Output:

0

Explanation:

Count E before X; neither O nor X qualifies. Exact input: "X"; exact output: "0\n".

Example 3

Input:

OOOEX

Output:

1

Explanation:

Count E before X; neither O nor X qualifies. Exact input: "OOOEX"; exact output: "1\n".

Note on displayed bytes: \n denotes an actual LF, \t an actual tab and \r an actual CR. The JSON-style Input renderings in explanations are diagnostic only, not extra input characters.