Problem:
Score : 300 points

Problem Statement

There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.

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

How many good observatories are there?

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq H_i \leq 10^9

1 \leq A_i,B_i \leq N

A_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:

N M
H_1 H_2 ... H_N
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Print the number of good observatories.

Sample Input 1

4 3
1 2 3 4
1 3
2 3
2 4

Sample Output 1

2

From Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.

From Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.

From Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.

From Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.

Thus, the good observatories are Obs. 3 and 4, so there are two good observatories.

Sample Input 2

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

Sample Output 2

3

Solution in C (GCC 9.2.1) (judge verdict: Runtime Error)

#include <stdio.h>
// #include <stdlib.h>

// const int MAX_TEMBODAI_NUMBER = 9999999;

typedef struct {
  unsigned int height;
  short is_good; // 0: 未定義, 1: 悪い展望台, 2: 良い展望台
} Tembodai;

// 降順
/* static int compareFunction(const void *lhs, const void *rhs) { */
/*   return ((Tembodai *)rhs)->height - ((Tembodai *)lhs)->height; */
/* } */

int main() {
  short tembodai_count, temboway_count;
  scanf("%hd %hd", &tembodai_count, &temboway_count);

  Tembodai tembodai[tembodai_count];
  for (short i = 0; i < tembodai_count; i += 1) {
    scanf("%d", &tembodai[i].height);
    tembodai[i].is_good = 0;
  }
  // qsort(tembodai, tembodai_count, sizeof(*tembodai), compareFunction);

  // short temboway_array[temboway_count][2];
  for (short j = 0; j < temboway_count; j += 1) {
    short tembodai_number_a, tembodai_number_b;
    scanf("%hd %hd", &tembodai_number_a, &tembodai_number_b);

    short tembodai_index_a = tembodai_number_a - 1;
    short tembodai_index_b = tembodai_number_b - 1;

    /* printf("%c", '\n'); */
    /* printf("%s", "tembodai_index_a は "); */
    /* printf("%hd", tembodai_index_a); */
    /* printf("%c", '\n'); */
    /* printf("%s", "tembodai_index_b は "); */
    /* printf("%hd", tembodai_index_b); */
    /* printf("%c", '\n'); */

    if (tembodai[tembodai_index_a].height > tembodai[tembodai_index_b].height) {
      // A の方が高いケース
      // A を良い展望台に変更
      tembodai[tembodai_index_a].is_good = 2;

      if (tembodai[tembodai_index_b].is_good < 2) {
        // B が良い展望台または未定義の展望台だった場合
        // B を悪い展望台に変更
        tembodai[tembodai_index_b].is_good = 1;
      }
    } else if (tembodai[tembodai_index_a].height < tembodai[tembodai_index_b].height) {
      // B の方が高いケース
      // B を良い展望台に変更
      tembodai[tembodai_index_b].is_good = 2;

      if (tembodai[tembodai_index_a].is_good < 2) {
        // A が良い展望台または未定義の展望台だった場合
        // A を悪い展望台に変更
        tembodai[tembodai_index_a].is_good = 1;
      }
    } else {
      // 高さが同じケース
      if (tembodai[tembodai_index_a].is_good == 0) {
        // A が未定義の展望台だった場合
        // A を悪い展望台に変更
        tembodai[tembodai_index_a].is_good = 1;
      }
      if (tembodai[tembodai_index_b].is_good == 0) {
        // B が未定義の展望台だった場合
        // B を悪い展望台に変更
        tembodai[tembodai_index_b].is_good = 1;
      }
    }

    /* printf("%c", '\n'); */
    /* printf("%s", "展望台 "); */
    /* printf("%hd", tembodai_index_a); */
    /* printf("%s", " の評価は "); */
    /* printf("%hd", tembodai[tembodai_index_a].is_good); */
    /* printf("%c", '\n'); */
    /* printf("%s", "展望台 "); */
    /* printf("%hd", tembodai_index_b); */
    /* printf("%s", " の評価は "); */
    /* printf("%hd", tembodai[tembodai_index_b].is_good); */
    /* printf("%c", '\n'); */
  }

  short output = 0;
  for (short k = 0; k < tembodai_count; k += 1) {
    /* printf("%c", '\n'); */
    /* printf("%s", "展望台 "); */
    /* printf("%hd", k); */
    /* printf("%s", " の評価は "); */
    /* printf("%hd", tembodai[k].is_good); */
    /* printf("%c", '\n'); */

    if (tembodai[k].is_good == 0) {
      // 展望台k が未定義の展望台だった場合
      // 展望台k は「一本の道を使って辿り着ける展望台が存在しない場合」に該当するので
      // 展望台k を良い展望台に変更
      tembodai[k].is_good = 2;
    }
    if (tembodai[k].is_good == 2) {
      output += 1;
    }
  }

  printf("%hd", output);
  printf("%c", '\n');

  return 0;
}