P5587 Typing Practice.

Description

Mr. R is practicing typing. There is a typing practice website. Given a reference text and an input box, it will calculate your accuracy and typing speed based on what you type. The characters you can type are lowercase letters, spaces, and `.` (a period). After you type a character, the cursor moves accordingly. The typed text has multiple lines. Mr. R can press the Enter key to start a new line, and after that the cursor moves to the beginning of the next line. Mr. R can also press the Backspace key (for convenience, we use `

Input Format

Mr. R will provide you with the reference text, his input, and the time spent, in this order. The reference text and the input are read as follows: given several lines of strings, ending with a single line `EOF`. The line `EOF` is not part of the text. The last line is an integer $T$, meaning he spent $T$ seconds typing. You may refer to the sample input/output files and the sample explanation for better understanding.

Output Format

Output one integer on a single line, representing the KPM.

Explanation/Hint

#### Sample Explanation The number of correct characters in the first line is 11. The number of correct characters in the second line is 6. The wrong character `c` still takes up one position. The number of correct characters in the third line is 1. Mr. R used Backspace to delete the incorrectly typed character `y`. #### Constraints For $20\%$ of the testdata, there is no Enter key. For $40\%$ of the testdata, there is no Backspace key. For $100\%$ of the testdata, $T \leq 10^3$, and the total number of characters (including newlines) in each text block is at most $10^5$, and the total number of lines is at most $10^4$. Translated by ChatGPT 5