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: Accepted)

#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

class UnionFind {
  public:
    // rank:それぞれの木の深さ
    vector<int> rank;
    // p:ポインタ的な配列
    vector<int> p;
    UnionFind() {}
    UnionFind(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);

        //最初は、全ての値は別の木に属するようにする
        //{0},{1},{2},...といった数字一つのみを持つ木が作られる
        for(int i = 0; i < size; i++) {
            makeSet(i);
        }
    };

    // ただ一つの要素xを持つ木を作成する
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

    // 要素xが属する木のルートノードの値を求める
    int findSet(int x) {
        // xがルートノードでないならポインタがさしている先を再帰的に探索する
        //ルートノードならreturnする
        if(x != p[x]) {
            //ここで最終的に返ってくるのはルートノードの値であるため、探索中に経由したすべてのノードのポインタはルートノードへとつながる。
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

    // xとyが同じ木に属しているか判定する
    bool isSame(int x, int y) { return findSet(x) == findSet(y); }

    // xを要素に持つ木とyを要素に持つ木を統合する
    void unite(int x, int y) { link(findSet(x), findSet(y)); }

  private:
    // xを根に持つ木とyを根に持つ木を統合する
    void link(int x, int y) {
        //なるべく木が深くならないように、rankが小さい方をrankが大きい方へ統合する
        if(rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            //木の深さが同じだったらどうしても一段深くなってしまう
            if(rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
};

const int MOD_NUM = 2;
// base : 9973
class RollingHash {
    vector<LL> hash[MOD_NUM];
    vector<LL> mod = {999999937LL, 1000000007LL};
    LL base = 9973;

  public:
    RollingHash(string s) { initialize(s); }

    vector<LL> getHashNum(int left, int right) {
        vector<LL> res(MOD_NUM);
        for(int i = 0; i < MOD_NUM; i++) {
            res[i] =
                ((hash[i][right] -
                  hash[i][left] * this->mpower(base, right - left, mod[i])) %
                     mod[i] +
                 mod[i]) %
                mod[i];
        }

        return res;
    }

  private:
    void initialize(string s) {
        for(int i = 0; i < MOD_NUM; i++) {
            hash[i].assign(s.size() + 1, 0);
            for(int j = 0; j < s.size(); j++) {
                hash[i][j + 1] = (hash[i][j] * base + s[j]) % mod[i];
            }
        }
    }

    LL mpower(LL x, LL n, LL mod) {
        if(n == 0) {
            return 1;
        } else if(n % 2 == 0) {
            return mpower(x * x % mod, n / 2, mod);
        } else {
            return x * mpower(x, n - 1, mod) % mod;
        }
    }
};

template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T lcm(T x, T y) { return x / __gcd(x, y) * y; }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}

template <class T> inline T q_power(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return q_power(x * x, n / 2);
    } else {
        return x * q_power(x, n - 1);
    }
}

LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> H(N);
    rep(i, N) cin >> H[i];

    vector<vector<int>> neighbor_H(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;

        neighbor_H[A].push_back(B);
        neighbor_H[B].push_back(A);
    }


    int ans = 0;
    rep(i, N) {
        if(neighbor_H[i].size() == 0) {
            ans++;
            continue;
        }

        rep(j, int(neighbor_H[i].size())) {
            if(H[i] <= H[neighbor_H[i][j]]) {
                break;
            }

            if(j == int(neighbor_H[i].size()) - 1) {
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}