#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> G[N];
int arr[N];
int pos[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    pos[arr[i]] = i;
  }
  int n_num = arr[n];
  vector<int> rec;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    if (v == n_num) rec.push_back(pos[u]);
  }
  sort(rec.begin(), rec.end(), greater<int>());
  for (int i = 0; i < rec.size(); i++) {
    int pos_u = rec[i];
    int u = arr[pos_u];
    for (int j = pos_u + 1; j <= n; j++) {
      if (*lower_bound(G[u].begin(), G[u].end(), arr[j]) == arr[j]) {
        swap(arr[j], arr[j - 1]);
      } else
        break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == n_num) printf("%d\n", n - i);
  }
  return 0;
}
