import collections

class Dinic:

    def __init__(self, n):

        self.n = n

        self.g = [[] for i in range(n)]

    def add_edge(self, fr, to, cap):

        self.g[fr].append([to, cap, len(self.g[to])])

        self.g[to].append([fr, 0, len(self.g[fr])-1])

    def add_multi_edge(self, v1, v2, cap1, cap2):

        self.g[v1].append([v2, cap1, len(self.g[v2])])

        self.g[v2].append([v1, cap2, len(self.g[v1])-1])

    def bfs(self, s):

        level = [-1]*self.n

        deq = collections.deque()

        level[s] = 0

        deq.append(s)

        while deq:

            v = deq.popleft()

            for e in self.g[v]:

                if e[1]>0 and level[e[0]]<0:

                    level[e[0]] = level[v] + 1

                    deq.append(e[0])

        self.level = level

    def dfs(self, v, t, f):

        if v==t: return f

        es = self.g[v]

        level = self.level

        for i in range(self.it[v], len(self.g[v])):

            e = es[i]

            if e[1]>0 and level[v]<level[e[0]]:

                d = self.dfs(e[0], t, min(f, e[1]))

                if d>0:

                    e[1] -= d

                    self.g[e[0]][e[2]][1] += d

                    self.it[v] = i

                    return d

        self.it[v] = len(self.g[v])

        return 0

    def max_flow(self, s, t):

        flow = 0

        while True:

            self.bfs(s)

            if self.level[t]<0: break

            self.it = [0]*self.n

            while True:

                f = self.dfs(s, t, 10**9+7)

                if f>0:

                    flow += f

                else:

                    break

        return flow



X, Y, E = list(map(int, input().split()))

dinic = Dinic(2+X+Y)

for i in range(X):

    dinic.add_edge(0, 2+i, 1)

for i in range(Y):

    dinic.add_edge(2+X+i, 1, 1)

for i in range(E):

    x, y = list(map(int, input().split()))

    dinic.add_edge(2+x, 2+X+y, 1)

print((dinic.max_flow(0, 1)))
# Hopcroft-Karp Algorithm

from collections import deque

class HopcroftKarp:

    def __init__(self, N0, N1):

        self.N0 = N0

        self.N1 = N1

        self.N = N = 2+N0+N1

        self.G = [[] for i in range(N)]

        for i in range(N0):

            forward = [2+i, 1, None]

            forward[2] = backward = [0, 0, forward]

            self.G[0].append(forward)

            self.G[2+i].append(backward)

        self.backwards = bs = []

        for i in range(N1):

            forward = [1, 1, None]

            forward[2] = backward = [2+N0+i, 0, forward]

            bs.append(backward)

            self.G[2+N0+i].append(forward)

            self.G[1].append(backward)



    def add_edge(self, fr, to):

        #assert 0 <= fr < self.N0

        #assert 0 <= to < self.N1

        v0 = 2 + fr

        v1 = 2 + self.N0 + to

        forward = [v1, 1, None]

        forward[2] = backward = [v0, 0, forward]

        self.G[v0].append(forward)

        self.G[v1].append(backward)



    def bfs(self):

        G = self.G

        level = [None]*self.N

        deq = deque([0])

        level[0] = 0

        while deq:

            v = deq.popleft()

            lv = level[v] + 1

            for w, cap, _ in G[v]:

                if cap and level[w] is None:

                    level[w] = lv

                    deq.append(w)

        self.level = level

        return level[1] is not None



    def dfs(self, v, t):

        if v == t:

            return 1

        level = self.level

        for e in self.it[v]:

            w, cap, rev = e

            if cap and level[v] < level[w] and self.dfs(w, t):

                e[1] = 0

                rev[1] = 1

                return 1

        return 0



    def flow(self):

        flow = 0

        N = self.N; G = self.G

        bfs = self.bfs; dfs = self.dfs

        while bfs():

            *self.it, = list(map(iter, G))

            while dfs(0, 1):

                flow += 1

        return flow



    def matching(self):

        return [cap for _, cap, _ in self.backwards]





import sys

readline = sys.stdin.readline

write = sys.stdout.write



X, Y, E = list(map(int, readline().split()))



hc = HopcroftKarp(X, Y)

for i in range(E):

    x, y = list(map(int, readline().split()))

    hc.add_edge(x, y)



write("%d\n" % hc.flow())



import collections


class Dinic:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in range(n)]

    def add_edge(self, fr, to, cap):
        self.g[fr].append([to, cap, len(self.g[to])])
        self.g[to].append([fr, 0, len(self.g[fr]) - 1])

    def add_multi_edge(self, v1, v2, cap1, cap2):
        self.g[v1].append([v2, cap1, len(self.g[v2])])
        self.g[v2].append([v1, cap2, len(self.g[v1]) - 1])

    def bfs(self, s):
        level = [-1] * self.n
        deq = collections.deque()
        level[s] = 0
        deq.append(s)
        while deq:
            v = deq.popleft()
            for e in self.g[v]:
                if e[1] > 0 and level[e[0]] < 0:
                    level[e[0]] = level[v] + 1
                    deq.append(e[0])
        self.level = level

    def dfs(self, v, t, f):
        if v == t:
            return f
        es = self.g[v]
        level = self.level
        for i in range(self.it[v], len(self.g[v])):
            e = es[i]
            if e[1] > 0 and level[v] < level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d > 0:
                    e[1] -= d
                    self.g[e[0]][e[2]][1] += d
                    self.it[v] = i
                    return d
        self.it[v] = len(self.g[v])
        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0:
                break
            self.it = [0] * self.n
            while True:
                f = self.dfs(s, t, 10**9 + 7)
                if f > 0:
                    flow += f
                else:
                    break
        return flow


X, Y, E = list(map(int, input().split()))
dinic = Dinic(2 + X + Y)
for i in range(X):
    dinic.add_edge(0, 2 + i, 1)
for i in range(Y):
    dinic.add_edge(2 + X + i, 1, 1)
for i in range(E):
    x, y = list(map(int, input().split()))
    dinic.add_edge(2 + x, 2 + X + y, 1)
print((dinic.max_flow(0, 1)))

# Hopcroft-Karp Algorithm
from collections import deque


class HopcroftKarp:
    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2 + N0 + N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2 + i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2 + i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2 + N0 + i, 0, forward]
            bs.append(backward)
            self.G[2 + N0 + i].append(forward)
            self.G[1].append(backward)

    def add_edge(self, fr, to):
        # assert 0 <= fr < self.N0
        # assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)

    def bfs(self):
        G = self.G
        level = [None] * self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None

    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0

    def flow(self):
        flow = 0
        N = self.N
        G = self.G
        bfs = self.bfs
        dfs = self.dfs
        while bfs():
            (*self.it,) = list(map(iter, G))
            while dfs(0, 1):
                flow += 1
        return flow

    def matching(self):
        return [cap for _, cap, _ in self.backwards]


import sys

readline = sys.stdin.readline
write = sys.stdout.write
X, Y, E = list(map(int, readline().split()))
hc = HopcroftKarp(X, Y)
for i in range(E):
    x, y = list(map(int, readline().split()))
    hc.add_edge(x, y)
write("%d\n" % hc.flow())

-import collections +# Hopcroft-Karp Algorithm +from collections import deque -class Dinic: -    def __init__(self, n): -        self.n = n -        self.g = [[] for i in range(n)] +class HopcroftKarp: +    def __init__(self, N0, N1): +        self.N0 = N0 +        self.N1 = N1 +        self.N = N = 2 + N0 + N1 +        self.G = [[] for i in range(N)] +        for i in range(N0): +            forward = [2 + i, 1, None] +            forward[2] = backward = [0, 0, forward] +            self.G[0].append(forward) +            self.G[2 + i].append(backward) +        self.backwards = bs = [] +        for i in range(N1): +            forward = [1, 1, None] +            forward[2] = backward = [2 + N0 + i, 0, forward] +            bs.append(backward) +            self.G[2 + N0 + i].append(forward) +            self.G[1].append(backward) -    def add_edge(self, fr, to, cap): -        self.g[fr].append([to, cap, len(self.g[to])]) -        self.g[to].append([fr, 0, len(self.g[fr]) - 1]) +    def add_edge(self, fr, to): +        # assert 0 <= fr < self.N0 +        # assert 0 <= to < self.N1 +        v0 = 2 + fr +        v1 = 2 + self.N0 + to +        forward = [v1, 1, None] +        forward[2] = backward = [v0, 0, forward] +        self.G[v0].append(forward) +        self.G[v1].append(backward) -    def add_multi_edge(self, v1, v2, cap1, cap2): -        self.g[v1].append([v2, cap1, len(self.g[v2])]) -        self.g[v2].append([v1, cap2, len(self.g[v1]) - 1]) - -    def bfs(self, s): -        level = [-1] * self.n -        deq = collections.deque() -        level[s] = 0 -        deq.append(s) +    def bfs(self): +        G = self.G +        level = [None] * self.N +        deq = deque([0]) +        level[0] = 0 -            for e in self.g[v]: -                if e[1] > 0 and level[e[0]] < 0: -                    level[e[0]] = level[v] + 1 -                    deq.append(e[0]) +            lv = level[v] + 1 +            for w, cap, _ in G[v]: +                if cap and level[w] is None: +                    level[w] = lv +                    deq.append(w) +        return level[1] is not None -    def dfs(self, v, t, f): +    def dfs(self, v, t): -            return f -        es = self.g[v] +            return 1 -        for i in range(self.it[v], len(self.g[v])): -            e = es[i] -            if e[1] > 0 and level[v] < level[e[0]]: -                d = self.dfs(e[0], t, min(f, e[1])) -                if d > 0: -                    e[1] -= d -                    self.g[e[0]][e[2]][1] += d -                    self.it[v] = i -                    return d -        self.it[v] = len(self.g[v]) +        for e in self.it[v]: +            w, cap, rev = e +            if cap and level[v] < level[w] and self.dfs(w, t): +                e[1] = 0 +                rev[1] = 1 +                return 1 -    def max_flow(self, s, t): +    def flow(self): -        while True: -            self.bfs(s) -            if self.level[t] < 0: -                break -            self.it = [0] * self.n -            while True: -                f = self.dfs(s, t, 10**9 + 7) -                if f > 0: -                    flow += f -                else: -                    break +        N = self.N +        G = self.G +        bfs = self.bfs +        dfs = self.dfs +        while bfs(): +            (*self.it,) = list(map(iter, G)) +            while dfs(0, 1): +                flow += 1 +    def matching(self): +        return [cap for _, cap, _ in self.backwards] -X, Y, E = list(map(int, input().split())) -dinic = Dinic(2 + X + Y) -for i in range(X): -    dinic.add_edge(0, 2 + i, 1) -for i in range(Y): -    dinic.add_edge(2 + X + i, 1, 1) + +import sys + +readline = sys.stdin.readline +write = sys.stdout.write +X, Y, E = list(map(int, readline().split())) +hc = HopcroftKarp(X, Y) -    x, y = list(map(int, input().split())) -    dinic.add_edge(2 + x, 2 + X + y, 1) -print((dinic.max_flow(0, 1))) +    x, y = list(map(int, readline().split())) +    hc.add_edge(x, y) +write("%d\n" % hc.flow())