#include <stdio.h>

int main() {
 int n,m,height,i,heightx,heighty;
 int ans;
 
 scanf("%d %d", &n, &m);
 
 int s[n];
 for(i = 0; i < n; i++) {
   scanf("%d", &height);
   s[i] = height;
 }
 
 int x[n];
 int y[n];
 for(i = 0; i < m; i++) {
   scanf("%d %d", &x, &y);
   x[i] = 1;
   /*heightx = x;
   heighty = y;
   if (!(s[heightx - 1] == s[heighty - 1])) */
     y[i] = 2;
 }
 
 ans = 0;
 for(i = 0; i < n; i++) {
   if ((x[i] == 0 && y[i] == 0) || y[i] == 2)
     ans++;
 }

 printf("%d", ans);
 return(0);
}