#K77397. Maximum Scenic Trails

    ID: 34855 Type: Default 1000ms 256MiB

Maximum Scenic Trails

Maximum Scenic Trails

You are given an undirected graph representing a network of scenic trails between locations. There are (n) locations and (m) bidirectional trails. Your task is to determine the maximum number of scenic trails a traveler can include in a journey without visiting any location more than once. In other words, find the maximum number of edges in any simple path in the graph.

A simple path is defined as a path that does not repeat any vertices. The answer is the maximum number of trails (edges) in such a path.

Note: Since finding longest simple paths in a general graph is NP-hard, it is assumed that the input sizes are small enough for an exhaustive search (depth-first search) approach to work.

inputFormat

The input is given via stdin and has the following format:

The first line contains two space-separated integers (n) and (m), where (n) is the number of locations and (m) is the number of scenic trails.

This is followed by (m) lines, each containing two space-separated integers (u) and (v), representing a trail between locations (u) and (v). These trails are bidirectional.

outputFormat

Output a single integer to stdout that represents the maximum number of scenic trails a traveler can include in a journey without visiting the same location more than once.## sample

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