Counting-Based Search for Constraint Optimization Problems