I can't remember, but if you're replacing one, watch out for wear in the push-rod pivot on the pedal arm. If the push-rod is no longer pushing directly in line with the cylinder bore, you will wear out a new one in a few weeks.
As an aside, if you have experienced fluid leakage into your carpet and you now have a soggy floor, hire a carpet shampooer/vacuum from the supermarket, pour a bucket of water into the footwell, and suck it out with the vacuum cleaner. You may need to repeat this a dozen times, but you end up with beautifully cleaner carpet, not brake fluid and very little moisture. Do it on a hot day and it will dry out even quicker. Doesn't bother the carpet machine at all. Brake fluid is soluble in water.
I'm pretty sure that they are the same diameter even though they look different on the outside, because I'm using a master cylinder originally out of a 504, in my 505 and it works fine.