How to assign numerical value in order per company to a property

Hey everyone,
I wanted to add a step in my workflow where I will assign a numerical value in order per company to a property.
Example:
contact A from company A - Assign number 1
contact B from company A - Assign number 2
contact C from company B - Assign number 1
contact D from company B - Assign number 2
Can this be done in custom code? Am I able to track what numbers I assigned to contact based on the company?

Hello @NGiron, I will add some top experts to share their thoughts, @Kevin-C @Dan1 what would you recommend to @NGiron matter?

Thank you,

Pam