#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
int p[maxn], pos[maxn];
int cnt[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]), pos[p[i]] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (pos[u] > pos[v]) continue;
    cnt[pos[u]]++;
  }
  int ans = 0;
  for (int i = n - 1; i >= 1; i--)
    if (cnt[i] == n - i) ans++;
  cout << ans << endl;
}
