atcoder#ABC166C. [ABC166C] Peaks

[ABC166C] Peaks

Score : 300300 points

Problem Statement

There are NN observatories in AtCoder Hill, called Obs. 11, Obs. 22, ......, Obs. NN. The elevation of Obs. ii is HiH_i. There are also MM roads, each connecting two different observatories. Road jj connects Obs. AjA_j and Obs. BjB_j.

Obs. ii is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. ii using just one road. Note that Obs. ii is also good when no observatory can be reached from Obs. ii using just one road.

How many good observatories are there?

Constraints

  • 2N1052 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • 1Hi1091 \leq H_i \leq 10^9
  • 1Ai,BiN1 \leq A_i,B_i \leq N
  • AiBiA_i \neq B_i
  • Multiple roads may connect the same pair of observatories.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

H1H_1 H2H_2 ...... HNH_N

A1A_1 B1B_1

A2A_2 B2B_2

::

AMA_M BMB_M

Output

Print the number of good observatories.

4 3
1 2 3 4
1 3
2 3
2 4
2
  • From Obs. 11, you can reach Obs. 33 using just one road. The elevation of Obs. 11 is not higher than that of Obs. 33, so Obs. 11 is not good.
  • From Obs. 22, you can reach Obs. 33 and 44 using just one road. The elevation of Obs. 22 is not higher than that of Obs. 33, so Obs. 22 is not good.
  • From Obs. 33, you can reach Obs. 11 and 22 using just one road. The elevation of Obs. 33 is higher than those of Obs. 11 and 22, so Obs. 33 is good.
  • From Obs. 44, you can reach Obs. 22 using just one road. The elevation of Obs. 44 is higher than that of Obs. 22, so Obs. 44 is good.

Thus, the good observatories are Obs. 33 and 44, so there are two good observatories.

6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6
3