unittest
{
	assert( [ "4 3", "1 2 3 4", "1 3", "2 3", "2 4" ].parse.expand.solve == 2 );
	assert( [ "6 5", "8 6 9 1 2 1", "1 3", "4 2", "4 3", "4 6", "4 6" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto hs = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	return tuple( hs, abs );
}

auto solve( long[] hs, long[ 2 ][] abs )
{
	auto nss = toAdjacencyList!true( hs.length, abs );
	auto ans = 0L;
	foreach( i, h; hs )
	{
		auto m = 0L;
		foreach( j; nss[ i ] )
		{
			m = max( m, hs[ j ] );
		}
		if( m < h ) ans++;
	}
	return ans;
}

// 辺配列から隣接リストを作成
auto toAdjacencyList( bool undirected = false )( long n, long[ 2 ][] es )
{
	auto nss = new long[][ n ];
	foreach( e; es )
	{
		nss[ e[ 0 ] ] ~= e[ 1 ];
		static if( undirected ) nss[ e[ 1 ] ] ~= e[ 0 ];
	}
	return nss;
}
