Friend Palindrome 2

Given friends split by parity into girls and boys and a friendship graph, choose the largest group that can be arranged so every non-middle person pairs with an opposite-sex friend.

Medium7GraphDynamic programmingBit manipulationCombinatoricsNo attempts yetTime limit2sMemory limit512 MB

Problem

Jaehong is an elementary school student. At this spring's school show he conducts while his classmates dance. The dance goes like this. The friends on stage first stand in a single line and each one improvises alone. Then, taking the middle of the line as the center, the ii-th friend from the left and the ii-th friend from the right take each other's hands and dance together. With five friends in line, the first and the fifth form a pair and the second and the fourth form a pair. The third friend, standing in the middle, has no partner, so that friend does a robot dance alone. One friend dances alone like this only when the number of friends on stage is odd.

Every classmate wants a partner who is a close friend, and wants a partner of the opposite sex. A boy must hold hands with a girl and a girl must hold hands with a boy. Jaehong wants a big show, so he puts as many friends on stage as he can. Given the friendships, find the largest number of friends he can put on stage and tell him. Friends are identified by roll numbers 11 through NN, and each friend has exactly one roll number.

Even if A and B are close friends and B and C are close friends, A and C are not necessarily close friends. Apart from the one friend doing the robot dance, everyone on stage must be paired with a close friend of the opposite sex. Any classmate can do the robot dance.

Girls and boys standing in a line

Input

The first line contains the number of classmates NN and the number of friendships MM, separated by a space. Jaehong is not counted. (2N2002 \le N \le 200, 0Mmin((N2N)/2,10000)0 \le M \le \min((N^2-N)/2, 10000))

Each of the next MM lines contains one friendship as two roll numbers uu and vv. uu and vv are different, and if uu and vv are close friends then vv and uu are close friends too. An odd roll number belongs to a girl and an even roll number belongs to a boy.

The same friendship is never given more than once. If 1 2 has already appeared, neither 1 2 nor 2 1 appears again.

Output

Print the largest number of friends that can go on stage, on one line.