While this basic tactic is important, it is ignored by most if not all chess books.
Dan Heisman definition of Counting is: "Determining whether any series of captures might lead to losing material".
Dan Heisman definition of Safe is: "A piece is safe if no possible sequence of exchanges on the square it occupies will lose material, assuming best play".
There are five ways to save an attacked usafe piece:
4 Protect the piece
5 Counterattack (the most dangerous)
including pinning, checking, attack another, capture.
In the case of the King, only the initial three are applicable.