#include <bits/stdc++.h>
using namespace std;
int N, M, A[300003], ans, num, B[300003], cnt[300003];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cin >> N >> M;
  for (int i = 1; i <= N; ++i) cin >> A[i], B[A[i]] = i;
  for (int i = 1, a, b; i <= M; ++i) {
    cin >> a >> b;
    if (B[a] < B[b]) ++cnt[B[a]];
  }
  for (int i = 1; i < N; ++i) ans += (cnt[i] == N - i);
  cout << ans << '\n';
  return 0;
}
