a,b=map(int,input().split()) c=list(map(int,input().split())) ans=0 zoff=[] strawberry=[[] for i in range(a)] very=sorted(set(c)) for _ in very: zoff.append(c.count(_)) for i in range(a-1): for j in range(i+1,a): if c[i]==c[j]: strawberry[i].append(j) strawberry[j].append(i) ans=sum(zoff)-len(zoff) for i in range(b): yaakiyu,kafeore=map(int,input().split()) if kafeore-1 in strawberry[yaakiyu-1]: ans-=1 print(ans)