#include <bits/stdc++.h>
using namespace std;
const int maxn = 300100;
int p[maxn], fav[maxn];
vector<int> ss[maxn];
int main() {
  int n, m, t1, t2, me;
  while (cin >> n >> m) {
    memset(fav, 0, sizeof fav);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &p[i]);
    }
    me = p[n];
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &t1, &t2);
      ss[t1].push_back(t2);
      ss[t2].push_back(t1);
      if (t1 == me)
        fav[t2]++;
      else if (t2 == me)
        fav[t1]++;
    }
    int ans = 0, remo = 0;
    for (int i = n - 1; i >= 1; i--) {
      int tt = n - i - remo;
      if (fav[p[i]] == tt) {
        remo++;
        ans++;
      } else {
        for (int j = 0; j < ss[p[i]].size(); j++) {
          fav[ss[p[i]][j]]++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
