#!/usr/bin/env python

# -*- coding: utf-8 -*-

"""

input:

3 4 6

0 0

0 2

0 3

1 1

2 1

2 3



output:

3

"""



import sys





def dfs(current, matching, visited):

    for target in range(y_num):

        if not visited[target] and target in adj_table[current]:

            visited[target] = True

            ''' Matching[target] = -1: target not assigned to any of x.

            And dfs(matching[target], matching, visited) = True

            indicates that source in x has been already assigned

            to another target in y. '''

            if matching[target] == -1 or dfs(matching[target], matching, visited):

                matching[target] = current

                return True

    return False





def mbm():

    res = 0

    matching = [-1] * y_num

    for source in range(x_num):

        visited = [False] * y_num

        if dfs(source, matching, visited):

            res += 1

    return res





if __name__ == '__main__':

    _input = sys.stdin.readlines()

    x_num, y_num, e_num = list(map(int, _input[0].split()))

    edges = [x.split() for x in _input[1:]]



    adj_table = tuple([] for _ in range(x_num))

    for edge in edges:

        vx, vy = list(map(int, edge))

        adj_table[vx].append(vy)

    print((mbm()))
#!/usr/bin/env python

# -*- coding: utf-8 -*-

"""

input:

3 4 6

0 0

0 2

0 3

1 1

2 1

2 3



output:

3

"""



import sys





def dfs(current, matching, visited):

    for target in range(y_num):

        if not visited[target] and target in adj_table[current]:

            visited[target] = True

            ''' Matching[target] = -1: target not assigned to any of x.

            And dfs(matching[target], matching, visited) = True

            indicates that source in x has been already assigned

            to another target in y. '''

            if matching[target] == -1 or dfs(matching[target], matching, visited):

                matching[target] = current

                return True

    return False





def mbm():

    res = 0

    matching = [-1] * y_num

    for source in range(x_num):

        visited = [False] * y_num

        if dfs(source, matching, visited):

            res += 1

    return res





if __name__ == '__main__':

    _input = sys.stdin.readlines()

    x_num, y_num, e_num = list(map(int, _input[0].split()))

    edges = [x.split() for x in _input[1:]]



    adj_table = tuple(set() for _ in range(x_num))

    for edge in edges:

        vx, vy = list(map(int, edge))

        adj_table[vx].add(vy)

    print((mbm()))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3
output:
3
"""
import sys


def dfs(current, matching, visited):
    for target in range(y_num):
        if not visited[target] and target in adj_table[current]:
            visited[target] = True
            """ Matching[target] = -1: target not assigned to any of x.
            And dfs(matching[target], matching, visited) = True
            indicates that source in x has been already assigned
            to another target in y. """
            if matching[target] == -1 or dfs(matching[target], matching, visited):
                matching[target] = current
                return True
    return False


def mbm():
    res = 0
    matching = [-1] * y_num
    for source in range(x_num):
        visited = [False] * y_num
        if dfs(source, matching, visited):
            res += 1
    return res


if __name__ == "__main__":
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = list(map(int, _input[0].split()))
    edges = [x.split() for x in _input[1:]]
    adj_table = tuple([] for _ in range(x_num))
    for edge in edges:
        vx, vy = list(map(int, edge))
        adj_table[vx].append(vy)
    print((mbm()))

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3
output:
3
"""
import sys


def dfs(current, matching, visited):
    for target in range(y_num):
        if not visited[target] and target in adj_table[current]:
            visited[target] = True
            """ Matching[target] = -1: target not assigned to any of x.
            And dfs(matching[target], matching, visited) = True
            indicates that source in x has been already assigned
            to another target in y. """
            if matching[target] == -1 or dfs(matching[target], matching, visited):
                matching[target] = current
                return True
    return False


def mbm():
    res = 0
    matching = [-1] * y_num
    for source in range(x_num):
        visited = [False] * y_num
        if dfs(source, matching, visited):
            res += 1
    return res


if __name__ == "__main__":
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = list(map(int, _input[0].split()))
    edges = [x.split() for x in _input[1:]]
    adj_table = tuple(set() for _ in range(x_num))
    for edge in edges:
        vx, vy = list(map(int, edge))
        adj_table[vx].add(vy)
    print((mbm()))

-    adj_table = tuple([] for _ in range(x_num)) +    adj_table = tuple(set() for _ in range(x_num)) -        adj_table[vx].append(vy) +        adj_table[vx].add(vy)