#C7863. Count the Highest Degree Nodes

    ID: 51781 Type: Default 1000ms 256MiB

Count the Highest Degree Nodes

Count the Highest Degree Nodes

You are given an undirected graph with N nodes and M edges. The nodes are numbered from 1 to N. Your task is to count the number of nodes that have the highest degree in the graph.

Recall that the degree of a node v is defined as the number of edges incident to v. In mathematical terms, if we denote the degree of a node v as \(deg(v)\), then:

$$deg(v)=\text{number of edges incident to } v$$

If there are no edges in the graph (i.e. \(M = 0\)), the answer is defined to be 0.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains two integers N and M, where N is the number of nodes and M is the number of edges.
  • The next M lines each contain two integers u and v representing an undirected edge between nodes u and v.

outputFormat

Print a single integer to standard output (stdout) representing the number of nodes with the highest degree.

## sample
4 5
1 2
2 3
2 4
3 4
1 3
2