#define _USE_MATH_DEFINES #include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //tuple #include //deque #include //INT_MAX #include //bitset #include //sqrt, ceil. M_PI, pow, sin #include //fixed #include //setprecision #include //stringstream #include //gcd, assumlate #include //randam_device #include //numeric_limits using namespace std; constexpr long long int D_MOD = 1000000007; int main() { int N, M; cin >> N >> M; vector> A(N); vector> B(N, vector(N)); int temp1, temp2; for (int i = 0; i < N; i++) { cin >> temp1; A.at(temp1 - 1).push_back(i + 1); } sort(A.rbegin(), A.rend()); for (int i = 0; i < M; i++) { cin >> temp1 >> temp2; B.at(temp1 - 1).at(temp2 - 1) = true; } int ans = 0; for (int i = 0; i < N; i++) { if (A.at(i).size() == 1) { continue; } else if (A.at(i).size() == 0) { break; } else { ans += A.at(i).size() - 1; for (unsigned int j = 0; j < A.at(i).size() - 1; j++) { for (unsigned int k = j + 1; k < A.at(i).size(); k++) { if (B.at(A.at(i).at(j) - 1).at(A.at(i).at(k) - 1) == true) { ans--; } } } } } cout << ans << endl; return 0; }