Stability of nuclei against pear-shaped deformations