from bisect import insort, bisect_left

n, k = map(int, raw_input().split())
p = map(int, raw_input().split())
indices = [[] for i in range(n+1)]


def issuperset(my_set, sub):
    my_set.sort()
    i = 0
    curr = sub[i]
    for v in my_set:
        if v == curr:
            i += 1
            if i < len(sub):
                curr = sub[i]
            else:
                return True
    return False


for i in range(k):
    q, w = map(int, raw_input().split())
    indices[q].append(w)

last = p[-1]
to_contain = set()
ans = 0


def contains(my_list, elem):
    ii = bisect_left(my_list, elem)
    return ii < len(my_list) and my_list[ii] == elem


for pup in p[-2::-1]:
    if contains(indices[pup], last):
        for c in to_contain:
            if not contains(indices[pup], c):
                to_contain.add(pup)
                ans -= 1
                break
        ans += 1
    else:
        to_contain.add(pup)
print ans