#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5 + 10;
int ord[MAX_N];
vector<int> G[MAX_N];
bool ok[MAX_N];
bool cmp(const int u, const int v) { return ord[u] < ord[v]; }
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &pos[i]);
    pos[i]--;
    ord[pos[i]] = i;
  }
  vector<int> take;
  int s = pos.back();
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    if (ord[u] < ord[v]) G[u].push_back(ord[v]);
    if (v == s) take.push_back(u);
  }
  for (int i = 0; i < n; i++) sort(begin(G[i]), end(G[i]));
  for (int i = 0; i < n; i++) {
    int p = ord[i];
    for (int j : G[i]) {
      if (p + 1 == j)
        p++;
      else
        break;
    }
    if (p == n - 1) ok[i] = true;
  }
  sort(begin(take), end(take), cmp);
  int ans = 0;
  while (not take.empty()) {
    int go = take.back();
    take.pop_back();
    if (ok[go])
      ans++;
    else
      break;
  }
  printf("%d\n", ans);
  return (0);
}
