Semaphore using 2 keys and 3 keys

In reply to dave_59:

Hello Dave,
Thanks you for the replay. But I couldn’t understand why each process needs 3 available keys?
To be clear: it created 4 keys then at a time it can get 3 keys. And put it back.

Can you please clear the doubt ?

Thank you in advance.