#P2944. Damaged Pastures

    ID: 16202 Type: Default 1000ms 256MiB

Damaged Pastures

Damaged Pastures

An earthquake has struck Farmer John's farm, damaging some pastures while leaving the cowpaths intact. The farm is modeled as \(P\) pastures (with \(1 \le P \le 3000\)) connected by \(C\) bidirectional cowpaths (with \(1 \le C \le 20000\)). The barn is located at pasture 1.

\(N\) cows (\(1 \le N \le P\)) call in, each reporting an undamaged pasture \(report_j\) (with \(2 \le report_j \le P\)) from which they cannot return to the barn because every path from that pasture to the barn goes through at least one damaged pasture. Note that the reported pastures are undamaged, and the barn (pasture 1) is also undamaged.

Your task is to determine the minimum number of pastures that must be damaged to explain these reports.

inputFormat

The first line contains three integers: (P), (C), and (N).\nThe next (C) lines each contain two integers (a_i) and (b_i), indicating a bidirectional cowpath between pastures (a_i) and (b_i).\nThe following (N) lines each contain one integer (report_j), indicating a reported undamaged pasture from which the cow cannot reach the barn.

outputFormat

Output a single integer: the minimum number of pastures that must be damaged.

sample

3 2 1
1 2
2 3
3
1