#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
const ll MOD = 998244353;
const int INF = 1e9 + 9;
const int MAXN = 500005;
int n, m, k, arr[MAXN], ch[MAXN], pos[MAXN], u, v, good, bad;
bool feasible = true;
char s[MAXN], t[MAXN];
void met() { return; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    if (pos[v] > pos[u]) ch[u]++;
  }
  for (int i = 1; i < n; i++) {
    if (ch[i] >= n - i - 1) good++;
  }
  cout << good << endl;
}
