import sys

from queue import deque



sys.setrecursionlimit(200000)





def hierarchize(source):

    global hierarchy

    hierarchy = [-1] * n

    queue = deque([(0, source)])

    while queue:

        h, v = queue.popleft()

        if hierarchy[v] != -1:

            continue

        hierarchy[v] = h

        if v == sink:

            return True

        queue.extend((h + 1, target)

                     for remain, target, _ in edges[v] if hierarchy[target] == -1 and remain)

    return False





def augment(v, limit):

    if v == sink:

        return limit

    res = 0

    for e in edges[v]:

        remain, target, idx = e

        if remain == 0 or hierarchy[v] >= hierarchy[target]:

            continue

        aug = augment(target, min(limit, remain))

        e[0] -= aug

        edges[target][idx][0] += aug

        res += aug

        limit -= aug

        if not limit:

            break

    return res





xn, yn, e = list(map(int, input().split()))

n = xn + yn + 2

sink = n - 1

edges = [[] for _ in range(n)]



hierarchy = [-1] * n



for x in range(xn):

    xi = x + 1

    edges[0].append([1, xi, 0])

    edges[xi].append([0, 0, x])

for y in range(yn):

    yi = xn + y + 1

    edges[yi].append([1, sink, y])

    edges[sink].append([0, yi, 0])



for _ in range(e):

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

    xi, yi = x + 1, xn + y + 1

    ex, ey = edges[xi], edges[yi]

    lx, ly = len(ex), len(ey)

    ex.append([1, yi, ly])

    ey.append([0, xi, lx])



res = 0

while hierarchize(0):

    res += augment(0, 100)

print(res)
def dfs(s):

    return _dfs(s, set())





def _dfs(v, visited):

    for u in edges[v]:

        if u in visited:

            continue

        visited.add(u)

        if matched[u] == -1 or _dfs(matched[u], visited):

            matched[u] = v

            return True

    return False





xn, yn, e = list(map(int, input().split()))

edges = [set() for _ in range(xn)]

matched = [-1] * yn



for _ in range(e):

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

    edges[x].add(y)



print((sum(map(dfs, list(range(xn))))))
import sys
from queue import deque

sys.setrecursionlimit(200000)


def hierarchize(source):
    global hierarchy
    hierarchy = [-1] * n
    queue = deque([(0, source)])
    while queue:
        h, v = queue.popleft()
        if hierarchy[v] != -1:
            continue
        hierarchy[v] = h
        if v == sink:
            return True
        queue.extend(
            (h + 1, target)
            for remain, target, _ in edges[v]
            if hierarchy[target] == -1 and remain
        )
    return False


def augment(v, limit):
    if v == sink:
        return limit
    res = 0
    for e in edges[v]:
        remain, target, idx = e
        if remain == 0 or hierarchy[v] >= hierarchy[target]:
            continue
        aug = augment(target, min(limit, remain))
        e[0] -= aug
        edges[target][idx][0] += aug
        res += aug
        limit -= aug
        if not limit:
            break
    return res


xn, yn, e = list(map(int, input().split()))
n = xn + yn + 2
sink = n - 1
edges = [[] for _ in range(n)]
hierarchy = [-1] * n
for x in range(xn):
    xi = x + 1
    edges[0].append([1, xi, 0])
    edges[xi].append([0, 0, x])
for y in range(yn):
    yi = xn + y + 1
    edges[yi].append([1, sink, y])
    edges[sink].append([0, yi, 0])
for _ in range(e):
    x, y = list(map(int, input().split()))
    xi, yi = x + 1, xn + y + 1
    ex, ey = edges[xi], edges[yi]
    lx, ly = len(ex), len(ey)
    ex.append([1, yi, ly])
    ey.append([0, xi, lx])
res = 0
while hierarchize(0):
    res += augment(0, 100)
print(res)

def dfs(s):
    return _dfs(s, set())


def _dfs(v, visited):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or _dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


xn, yn, e = list(map(int, input().split()))
edges = [set() for _ in range(xn)]
matched = [-1] * yn
for _ in range(e):
    x, y = list(map(int, input().split()))
    edges[x].add(y)
print((sum(map(dfs, list(range(xn))))))

-import sys -from queue import deque - -sys.setrecursionlimit(200000) +def dfs(s): +    return _dfs(s, set()) -def hierarchize(source): -    global hierarchy -    hierarchy = [-1] * n -    queue = deque([(0, source)]) -    while queue: -        h, v = queue.popleft() -        if hierarchy[v] != -1: +def _dfs(v, visited): +    for u in edges[v]: +        if u in visited: -        hierarchy[v] = h -        if v == sink: +        visited.add(u) +        if matched[u] == -1 or _dfs(matched[u], visited): +            matched[u] = v -        queue.extend( -            (h + 1, target) -            for remain, target, _ in edges[v] -            if hierarchy[target] == -1 and remain -        ) -def augment(v, limit): -    if v == sink: -        return limit -    res = 0 -    for e in edges[v]: -        remain, target, idx = e -        if remain == 0 or hierarchy[v] >= hierarchy[target]: -            continue -        aug = augment(target, min(limit, remain)) -        e[0] -= aug -        edges[target][idx][0] += aug -        res += aug -        limit -= aug -        if not limit: -            break -    return res - - -n = xn + yn + 2 -sink = n - 1 -edges = [[] for _ in range(n)] -hierarchy = [-1] * n -for x in range(xn): -    xi = x + 1 -    edges[0].append([1, xi, 0]) -    edges[xi].append([0, 0, x]) -for y in range(yn): -    yi = xn + y + 1 -    edges[yi].append([1, sink, y]) -    edges[sink].append([0, yi, 0]) +edges = [set() for _ in range(xn)] +matched = [-1] * yn -    xi, yi = x + 1, xn + y + 1 -    ex, ey = edges[xi], edges[yi] -    lx, ly = len(ex), len(ey) -    ex.append([1, yi, ly]) -    ey.append([0, xi, lx]) -res = 0 -while hierarchize(0): -    res += augment(0, 100) -print(res) +    edges[x].add(y) +print((sum(map(dfs, list(range(xn))))))