You need to use results, I think. This might be wrong, because I'm typing on my phone without consulting the reference, but something like this:
Code:
(+
(results
from:(sites Occupied by:P1)
to:0
(count Steps
(from)
(sites Top)
)
)
)