#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int N, M;
	int H[100000];

	int cnt = 0;

	scanf("%d%d", &N, &M);

	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);

	int a[2] = { 0 }, b[2] = { 0 };
	int isBig = 1;
	for (int i = 0; i < M; i++) {
		a[1] = a[0];
		b[1] = b[0];
		scanf("%d %d", &a[0], &b[0]);

		if (H[a[0] - 1] > H[b[0] - 1]) isBig = 1;
		else isBig = 0;

		if (i != 0)
			if (a[1] != a[0])
				if (isBig == 1) cnt++;

	}

	for (int i = a[0]; i < N; i++) cnt++;

	printf("%d\n", cnt);

	return 0;
}