#include<stdio.h>
int ounyu(int *data,int num,int cnt,int kl) {
  int n;
  data[cnt] = data[cnt - 1];
  for (n = cnt - 1; n != kl;n --){
    data[n] = data[n - 1];
  }
  data[kl] = num;
}
int syoujun (int *data,int num,int cnt) {
  int kl;
  if (cnt == 0) {
    data[0] = num;
  }
  else {
    for (kl = 0;kl <= cnt - 1;kl ++) {
      if (num <= data[kl]) {
        ounyu(data,num,cnt,kl);
      }
      else  if (kl == cnt - 1) {
        data[kl + 1] = num;
      }
      else{
        continue;
      }
    }
  }
}
int main() {
  int x,temp,cnt,s,t,i,n,m,h[100000],a[100000],b[100000],excld[100000];
  scanf("%d %d",&n,&m);

  for (i = 0;i <= n - 1;i ++) {
    scanf("%d",&h[i]);
  }
  for (i = 0;i <= m;i ++) {
    scanf("%d %d",&a[i],&b[i]);
  }

  x = 0;
  excld[0] = 0;
  s = 0;
  cnt = 0;
  for (i = 0;i <= n - 1;i ++) {
    if (i == excld[s]) {
      s += 1;
      continue;
    }
    else {
      for (t = 0;t <= m - 1;t ++) {
        if (i + 1 == a[t]) {
          if (a[t] > b[t]) {
            syoujun(excld,b[t],cnt);
            cnt ++;
            continue;
          }
          else if (t == m - 1) {
            x ++;
          }
          else {
            break;
            }
          }
        else if (i + 1 == b[t]) {
          if (b[t] > a[t]) {
            syoujun(excld,a[t],cnt);
            cnt ++;
            continue;
          }
          else if (t == m - 1) {
            x ++;
          }
          else {
            break;
            }
         }
        }
      }
    }
    printf("%d",x);
  }
