count_states is an API-only function which returns the number of states in the selection.
cmd.count_states(string selection="(all)")
Frame