#P7183. [CRCI2008-2009] NOP
[CRCI2008-2009] NOP
Problem Description
Mirko bought a new microprocessor.
Unfortunately, he found that many programs written for the old processor could not run on the new processor.
After carefully studying the manuals of the two processors, he found the reason.
To work faster, the new processor model imposes certain constraints on the machine code of programs, and these constraints did not exist in the previous model.
The processor’s machine code consists of instructions executed in order. Each instruction uses one byte of memory.
Also, an instruction can have or more parameters, and each parameter uses one additional byte of memory. In machine code, the parameters come immediately after the instruction.
When written in text form, machine code instructions are uppercase letters, and parameters are lowercase letters. For example:

This program consists of four instructions: the st uses three parameters, the nd uses two parameters, the rd uses none, and the th uses four parameters. The program uses bytes of memory.
The new processor model fetches memory in blocks of four bytes, so each instruction must start at a memory address divisible by (the first byte in memory has address ).
We can insert NOP (No Operation) instructions into an old program. These instructions do nothing.

Instructions , , , and are now located at memory positions , , , and , which satisfies the processor’s constraint.
Please write a program to find the minimum number of NOP instructions that need to be inserted.
Input Format
One line with a string , representing the machine code of a program written for the old processor model.
The program will always start with instruction, that is, the first character in the machine code is an uppercase letter. If an instruction appears multiple times in the machine code, it will always use the same number of parameters.
Output Format
One line with a positive integer , representing the minimum number of NOP instructions that need to be inserted.
Abcd
0
EaEbFabG
5
AbcbBccCDefgh
4
Hint
Constraints
Let be the number of characters in string . For of the testdata, .
Notes
- This problem is worth points in total.
- This problem is translated from COCI2008-2009 CRCI2008-2009 NOP. Translator: https://www.luogu.com.cn/user/219791
Translated by ChatGPT 5