n, m = map(int, input().split()) c = list(map(int, input().split())) cnt = [set() for _ in range(n)] for i in range(n): cnt[c[i]-1].add(i) s = set() edge = [0]*n for _ in range(m): v, u = map(int, input().split()) v -= 1 u -= 1 if c[v] == c[u]: if (v, u) not in s and (u, v) not in s: edge[c[v]-1] += 1 s.add((v, u)) s.add((u, v)) ans = 0 for e, t in zip(edge, cnt): if len(t) == 0: continue ans += max(len(t)-1-e, 0) print(ans)