#include<bits/stdc++.h>
using namespace std;

vector<int> towns[50000];
pair<int, int> groups[100];

bool f(int g, int a)
{
    if(g == a) return true;

    for(int i = 0; i < towns[g].size(); i++)
    {
        f(towns[g][i], a);
    }
}

int main()
{
    int N, M, K;
    int ans = 0;

    cin >> N;
    cin >> M;
    cin >> K;

    for(int i = 0; i < M; i++)
    {
        int a, b;

        cin >> a; cin >> b;
        a--; b--;

        towns[a].push_back(b);
    }

    for(int i = 0; i < K; i++)
    {
        cin >> groups[i].first; cin >> groups[i].second;
        groups[i].first--; groups[i].second--;
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < K; j++)
        {
            //cout << groups[j].second << " " << i << endl;
            if(f(groups[j].second, i) == true)
            {
                ans++;
                //cout << i << endl;
            }
        }
    }

    cout << ans << endl;

    return 0;
}
