Combinatorics of locally optimal RNA secondary structures