#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void sort(T& a) {
  sort(a.begin(), a.end());
}
template <class T>
inline void rsort(T& a) {
  sort(a.rbegin(), a.rend());
}
template <class T>
inline void reverse(T& a) {
  reverse(a.begin(), a.end());
}
template <class T>
inline int size(T& a) {
  int b = a.size();
  return b;
}
template <class T1, class T2>
inline void chkmin(T1& first, T2 second) {
  if (first > second) first = second;
}
template <class T1, class T2>
inline void chkmax(T1& first, T2 second) {
  if (first < second) first = second;
}
template <typename T>
inline ostream& operator<<(ostream& os, vector<T>& a) {
  for (int i = 0; i < size(a); i++) {
    os << a[i] << " ";
  }
  return os;
}
template <typename T>
inline istream& operator>>(istream& is, vector<T>& a) {
  for (int i = 0; i < size(a); i++) {
    is >> a[i];
  }
  return is;
}
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, pair<T1, T2>& a) {
  cout << "{" << a.first << ", " << a.second << "}";
  return os;
}
vector<int> p;
bool comp(int a, int b) { return (p[a] > p[b]); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  p.resize(n + 1);
  cin >> a;
  for (int i = 0; i < n; i++) {
    p[a[i]] = i;
  }
  int nas = a[n - 1];
  vector<vector<int>> graph(n + 1);
  int first, second;
  vector<int> inter;
  for (int i = 0; i < m; i++) {
    cin >> first >> second;
    if (second == nas) {
      inter.push_back(first);
    }
    graph[first].push_back(second);
  }
  sort(inter.begin(), inter.end(), comp);
  for (int i = 0; i < inter.size(); i++) {
    int l = 0;
    int v = inter[i];
    for (int j = 0; j < graph[v].size(); j++) {
      if (p[graph[v][j]] > p[v] && p[graph[v][j]] < n - i) {
        l++;
      }
    }
    if (l < n - i - p[v] - 1) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << inter.size();
}
