iCloud policy for counting the storage Photos uses

I’m getting ready to delete some old photos to free up iCloud storage space. I have shared some of these photos in iCloud Shared Albums. If I delete one from my own photos, but not from the shared album, does this free up any space? Or does Apple only count each photo once regardless of how many shared albums it’s in? How does iCloud storage count photos you share in Shared Albums? What about photos that are shared with you in Shared Albums?

Additionally, are photos sent via Messages counted separately than photos in Photos.app? So if I take a 3 MB photo of my cat, text it to my wife, and add it to a shared album, does this take 3, 6, or 9 MB of iCloud storage?