import heapq
import sys
from collections import defaultdict, Counter
from functools import reduce


n, m = list(map(int, input().split()))

p = list(map(int, input().split()))
g = defaultdict(list)
for i in range(m):
    a, b = list(map(int, input().split()))
    g[a].append(b)
used = {p[-1]}
ans = 0
for i in range(n-2, -1, -1):
    c = 0
    for u in g[p[i]]:
        if u in used:
            c+=1
    if c == (n - i - 1):
        ans += 1
    used.add(p[i])
print(ans)