#P10942. GF和猫咪的玩具

GF和猫咪的玩具

Problem Description

Student GF and a cat got a special toy. The toy consists of nn metal rings (numbered 1n1 \sim n) and mm ropes. Each rope connects two different metal rings, and all ropes have the same length. GF picks up ring LL with his left hand, and the cat picks up ring R (LR)R\ (L \ne R) with its right hand (or paw). Then they pull as hard as possible in opposite directions. GF wants to choose suitable LL and RR so that the number of ropes that become taut is as large as possible.

Note: If, as in the sample, 12435611 \to 2 \to 4 \to 3 \to 5 \to 6 \to 1 forms a cycle, we consider that when pulling 11 and 33, only one side can be made taut (12431 \to 2 \to 4 \to 3 or 35613 \to 5 \to 6 \to 1), and it does not count as making all of them taut. In plain words, when there are multiple connection ways between two rings with the same number of ropes, only one of these ways is counted as being made taut, not all of them.

Input Format

The first line contains two positive integers n,mn, m (n100n \le 100).

The next mm lines each contain two positive integers a,ba, b, meaning there is a rope connecting aa and bb.

Output Format

Only one integer, representing the maximum number of ropes that can be made taut.

6 6
1 2
1 6
2 4
6 5
4 3
5 3
3

Hint

Translated by ChatGPT 5