#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  g.resize(n);
  vector<int> seq(n);
  vector<int> ind(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
    ind[p[i]] = i;
  }
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    if (ind[to] > ind[from]) g[from].push_back(to);
  }
  vector<bool> P(n);
  P[p[n - 1]] = true;
  int psz = 0;
  psz++;
  for (int suf = 1; suf < n; suf++) {
    int count = 0;
    for (int j = 0; j < g[ind[n - suf - 1]].size(); j++) {
      int to = g[ind[n - suf - 1]][j];
      if (P[to]) count++;
    }
    if (count != psz) {
      P[ind[n - suf - 1]] = true;
      psz++;
    }
  }
  int ans = n;
  for (int i = 0; i < P.size(); i++)
    if (P[i]) ans--;
  cout << ans;
  return 0;
}
