n, m = map(int, raw_input().split())
p = map(int, raw_input().split())
e = [{} for i in range(n + 1)]
for i in range(m):
    u, v = map(int, raw_input().split())
    e[v][u] = 1

h = [p[-1]]
c = 0
for i in reversed(range(n - 1)):
    k = True
    for ph in h:
        if p[i] not in e[ph]:
            h.append(p[i])
            k = False
            break
    if k: c += 1
print c
