Rsidence time in gromacs?

GROMACS version:
GROMACS modification: Yes/No
Dear all

I want to calculate average residence time of water in the first hydration shell near N+ in polymer chain in last 5 ns of my run. Actually, I don’t know how to calculate it. What command(s) can be used for that?

Thank you in advancs