An Exact Algorithm for F-Measure Maximization