#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1LL)
#define bitset(a,b)      ( a |= (1LL << b))
#define bitunset(a,b)    (a &= ~(1LL << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
pii Dir[8] = {
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


pii operator+(pii obj, pii obj2) {
	return MP(obj.first + obj2.first, obj.second + obj2.second);
}
pii operator-(pii obj, pii obj2) {
	return MP(obj.first - obj2.first, obj.second - obj2.second);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//??????
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
class DGraph : public Graph {//??????
public:
	DGraph(int n) : Graph(n) {}
	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		sumcost++;
	}
};


class RGraph {//????????°??????
	struct edge{
		int to, cap = 0, rev;
		bool isrev;
	};
public:
	int sumflow = 0;

	vector<vector<edge>> g;

	RGraph(DGraph dg) : g(dg.g.size()){
		REP(i, dg.g.size()) {
			for (auto itr : dg.g[i]) {
				g[i].push_back({ itr.first, itr.second, (int)g[itr.first].size(), 0});
				g[itr.first].push_back({ i, 0, (int)g[i].size() - 1, 1});
			}
		}
	}

	void flow(edge& eg, int rate) {
		eg.cap -= rate;
		g[eg.to][eg.rev].cap += rate;
	}

};

RGraph FordFurkerson(DGraph g, int st, int en) {
	
	RGraph rg(g);

	vector<bool> used(g.g.size());

	function<int(int, int, int)> dfs = [&](int c, int p, int Min) {
		if (c == en) return Min;
		if (used[c]) return -1;
		used[c] = true;

		for (auto& itr : rg.g[c]) {
			if (itr.cap > 0) {
				int ret = dfs(itr.to, c, min(Min, itr.cap));
				if (ret != -1) {
					rg.flow(itr, ret);
					return ret;
				}
			}
		}

		return -1;
	};

	while (int zo = dfs(st, -1, INT_MAX) != -1) {
		fill(ALL(used), 0);
		rg.sumflow += zo;
	}

	return rg;
}

vector<int> BiMaxmatching(DGraph g, int scount) { // scount????????????????????´??§???g???????????????scount???
	
	g.g.push_back(vector<pii>());
	g.g.push_back(vector<pii>());

	REP(i, scount) {
		g.con(g.g.size() - 2, i);
	}
	rep(i, scount, g.g.size() - 2) {
		g.con(i, g.g.size() - 1);
	}

	RGraph rg(FordFurkerson(g, g.g.size() - 2, g.g.size() - 1));

	vector<int> ans(scount, -1);

	REP(i, scount) {
		for (auto itr : rg.g[i]) {
			if (!itr.isrev && !itr.cap) {
				ans[i] = itr.to;
			}
		}
	}

	return ans;
}

int main() {
	int x, y, e;
	cin >> x >> y >> e;

	DGraph g(x + y);

	REP(i, e) {
		int a, b;
		scanf("%d %d", &a, &b);
		g.con(a,b + x);
	}
	
	vector<int> ans(BiMaxmatching(g, x));

	int cou = 0;
	for (auto itr : ans)
		cou += itr != -1;

	cout << cou << endl;

	return 0;
}

Measured memory_bytes: 3672