#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
char buf[10000000], *ptr = buf - 1;
inline int readint(){
int f = 1, n = 0;
char ch = *++ptr;
while(ch < ‘0‘ || ch > ‘9‘){
if(ch == ‘-‘) f = -1;
ch = *++ptr;
}
while(ch <= ‘9‘ && ch >= ‘0‘){
n = (n << 1) + (n << 3) + ch - ‘0‘;
ch = *++ptr;
}
return f * n;
}
const int maxn = 1000 + 10, maxm = 10000 + 10;
struct Edge{
int to, next;
Edge(){}
Edge(int _t, int _n): to(_t), next(_n){}
}e[maxm];
int fir[maxn] = {0}, cnt = 0;
inline void add(int u, int v){
e[++cnt] = Edge(v, fir[u]); fir[u] = cnt;
}
int k, n, m, ans = 0;
int w[maxn], f[maxn] = {0}, vis[maxn] = {0};
int q[maxn], h, t;
void work(){
for(int u, v, i = 1; i <= k; i++){
h = t = 0;
q[t++] = w[i];
vis[w[i]] = i;
while(h != t){
u = q[h++];
f[u]++;
for(int j = fir[u]; j; j = e[j].next){
v = e[j].to;
if(vis[v] != i){
q[t++] = v;
vis[v] = i;
}
}
}
}
for(int i = 1; i <= n; i++)
if(f[i] == k) ans++;
}
int main(){
fread(buf, sizeof(char), sizeof(buf), stdin);
k = readint();
n = readint();
m = readint();
for(int i = 1; i <= k; i++) w[i] = readint();
for(int u, v, i = 1; i <= m; i++){
u = readint();
v = readint();
add(u, v);
}
work();
printf("%d\n", ans);
return 0;
}