@staticmethod
def d_3():
    (n, g, e) = map(int, sys.stdin.readline().split())
    graph = GeometryTopology.Graph()
    for i in range((n + 1)):
        graph.add_node(i)
    for p in [int(x) for x in sys.stdin.readline().split()]:
        graph.add_edge(p, n, capacity=1)
    for (a, b) in zip(*([map(int, sys.stdin.read().split())] * 2)):
        graph.add_edge(a, b, capacity=1)
        graph.add_edge(b, a, capacity=1)
    print(graph.dinic(0, n))
@staticmethod
def d_3():
    (n, g, e) = map(int, sys.stdin.readline().split())
    graph = GeometryTopology.Graph()
    for i in range((n + 1)):
        graph.add_node(i)
    for p in [int(x) for x in sys.stdin.readline().split()]:
        graph.add_edge(p, n, capacity=1)
    for (a, b) in zip(*([map(int, sys.stdin.read().split())] * 2)):
        graph.add_edge(a, b, capacity=1)
        graph.add_edge(b, a, capacity=1)
    print(graph.dinic(0, n))