Coordination number

dear all, I run a MD simulation; using 1 anion and 100 water molecules ? I can calculate the RDF of this ion with all O atoms of water molecules as set? but how to calculate the coordination number (salvation shell) of the anion with water molecules? I search the thread for coordination number , but unfortunately is not working ?