This is a goofy question, because the method of counting is not very well defined.
23 + 5x + 7y - x - 5 - 27
Let's make everything an addition because addition is associative but subtraction isn't.
= 23 + 5x + 7y + -x + -5 + -27
OK, let's commute a few things
= 5x + 7y + -x + -5 + -27 + 23
= 5x + -x + 7y + -5 + -27 + 23
That's two commutations.
= (5x + -x) + 7y + ((-5 + -27) + 23)
I'll count that as three associations
= (5 + -1)x + 7y + -9
That's a distributive law (in reverse which is fine)
= 4x + 7y - 9
Tallying that's associative law 3 times, commutative law 2 times, distributive law 1 time.