#include <iostream>
#include <string.h>
using namespace std;
int k, n, m;
int xx, yy;
typedef struct {
int xq[1001][1001];
int vis[1001];
}MuChang;
int sum[1001];
int Niu[1001];
int ans;
MuChang z;
void dfs(int x) {
for (int i = 1; i <= n; i++) {
if (z.vis[i] == 0 && z.xq[x][i] == 1) {
z.vis[i] = 1;
sum[i]++;
dfs(i);
}
}
}
int main() {
cin >> k >> n >> m; //输入奶牛的个数 牧场的个数 牧场之间多少条道路
for (int i = 1; i <= k; i++) {
cin >> Niu[i];
sum[Niu[i]]++;
}
for (int i = 1; i <= m; i++) {
cin >> xx >> yy;
z.xq[xx][yy] = 1;
}
for (int i = 1; i <= k; i++) {
memset(z.vis, 0, sizeof(z.vis));
dfs(Niu[i]);
}
for (int i = 1; i <= n; i++) {
if (sum[i] == k) {
ans++;
}
}
cout << ans << endl;
return 0;
}