#include <bits/stdc++.h>
using namespace std;
int dx[] = {+1, -1, 0, 0};
int dy[] = {0, 0, +1, -1};
int n, m, k;
int c[500005];
pair<int, int> pr[500005];
vector<int> vt[500005];
bool ok[500005];
int color[500005];
vector<int> vec[500005];
int valid;
int sub[500005];
int subCnt[500005];
void bicolor(int node, int cur, int subgrp) {
  if (ok[c[node]]) return;
  if (color[node] != -1) {
    if (cur != color[node]) ok[c[node]] = true;
    return;
  }
  color[node] = cur;
  sub[node] = subgrp;
  for (int i = 0; i < vt[node].size(); i++) {
    bicolor(vt[node][i], color[node] ^ 1, subgrp);
  }
}
bool cmp(int &tmp, int &tpp) { return (c[pr[tmp].second] < c[pr[tpp].second]); }
int Fix[2][500005];
vector<int> newVt[2][500005];
vector<int> newEx[2][500005];
vector<int> newWye[2][500005];
int TryToFix(int type, int node, int cur) {
  if (Fix[type][node] != -1) {
    if (Fix[type][node] != cur) return 0;
    return 1;
  }
  Fix[type][node] = cur;
  int res = 1;
  for (int i = 0; i < newVt[type][node].size(); i++) {
    int lol = Fix[type][node] ^ color[newEx[type][node][i]] ^ 1 ^
              color[newWye[type][node][i]];
    res *= TryToFix(type ^ 1, newVt[type][node][i], lol);
  }
  return res;
}
void inserter(int x, int y) {
  newVt[0][sub[x]].push_back(sub[y]);
  newEx[0][sub[x]].push_back(x);
  newWye[0][sub[x]].push_back(y);
  newVt[1][sub[y]].push_back(sub[x]);
  newEx[1][sub[y]].push_back(y);
  newWye[1][sub[y]].push_back(x);
}
void clearer(int x, int y) {
  newVt[0][sub[x]].clear();
  newEx[0][sub[x]].clear();
  newWye[0][sub[x]].clear();
  newVt[1][sub[y]].clear();
  newEx[1][sub[y]].clear();
  newWye[1][sub[y]].clear();
}
int process(int now) {
  int impCnt = 0;
  for (int i = 0; i < vec[now].size();) {
    int j = i;
    int res = 1;
    while (j < vec[now].size() &&
           c[pr[vec[now][i]].second] == c[pr[vec[now][j]].second]) {
      int x = pr[vec[now][j]].first;
      int y = pr[vec[now][j]].second;
      inserter(x, y);
      ++j;
    }
    for (int lol = i; lol < j; ++lol) {
      int x = pr[vec[now][lol]].first;
      int y = pr[vec[now][lol]].second;
      if (Fix[0][sub[x]] == -1) res *= TryToFix(0, sub[x], 0);
    }
    while (i < j) {
      int x = pr[vec[now][i]].first;
      int y = pr[vec[now][i]].second;
      clearer(x, y);
      Fix[0][sub[x]] = -1;
      Fix[1][sub[y]] = -1;
      ++i;
    }
    if (res == 0) impCnt++;
  }
  return (valid - 1 - impCnt);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  valid = k;
  for (int i = 1; i <= m; i++) {
    cin >> pr[i].first >> pr[i].second;
    if (c[pr[i].first] > c[pr[i].second]) swap(pr[i].first, pr[i].second);
    if (c[pr[i].first] == c[pr[i].second]) {
      vt[pr[i].first].push_back(pr[i].second);
      vt[pr[i].second].push_back(pr[i].first);
    }
  }
  memset(color, -1, sizeof(color));
  for (int i = 1; i <= n; i++)
    if (color[i] == -1) {
      subCnt[c[i]]++;
      bicolor(i, 0, subCnt[c[i]]);
    }
  for (int i = 1; i <= m; i++) {
    if (c[pr[i].first] == c[pr[i].second] || ok[c[pr[i].first]] ||
        ok[c[pr[i].second]])
      continue;
    vec[c[pr[i].first]].push_back(i);
  }
  for (int i = 1; i <= k; i++) {
    if (ok[i]) valid--;
    sort(vec[i].begin(), vec[i].end(), cmp);
  }
  memset(Fix, -1, sizeof(Fix));
  long long ans = 0;
  for (int i = 1; i <= k; i++) {
    if (ok[i]) continue;
    ans += process(i);
    --valid;
  }
  cout << ans << endl;
  return 0;
}
