added count of valid brackets