#include <stdio.h>

int meumax(int a, int b) {
    return (a > b) ? a : b;
}

int main() {
    int n, k, h, a, b, c = 0;
    int obs[1000000], vc[1000000];
    
    scanf("%d%d", &n, &k);
    
    for (int i = 0; i < n; ++i)
        scanf("%d", &obs[i]);
    
    for (int i = 0; i < k; ++i)
        vc[i] = 0;
    
    for (int i = 0; i < k; ++i) {
        scanf("%d%d", &a, &b);
        vc[meumax(a, b) - 1] = 1;
    }

    for (int i = 0; i <= k; ++i)
        if (vc[i] == 1)
            ++c;
    
    printf("%d", c);

    return 0;
}