#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

struct edge { int to, rev; int cap; };
void add_edge(vector<vector<edge>>& G, int u, int v, int c) {
   G[u].push_back((edge){ v, SZ(G[v])  , c });
   G[v].push_back((edge){ u, SZ(G[u])-1, 0 });
}
int dfs(vector< vector<edge> >& G, vector<bool>& used, int v, int t, int flow)
{
   if (v == t) return flow;
   used[v] = true;
   for(int i = 0; i < G[v].size(); ++i) {
      edge& e = G[v][i];
      if (used[e.to] || e.cap == 0) continue;
      int d = dfs(G, used, e.to, t, min(e.cap, flow));
      if (d > 0) {
         e.cap -= d;
         G[e.to][e.rev].cap += d;
         return d;
      }
   }
   return 0;
}
int max_flow(vector< vector<edge> >& G, int s, int t)
{
   int flow = 0;
   vector<bool> used(G.size());
   for (;;) {
      fill(used.begin(), used.end(), false);
      int f = dfs(G, used, s, t, INF);
      if (f == 0) return flow;
      flow += f;
   }
}

signed main()
{
   int a, b, m; cin >> a >> b >> m;
   V<V<edge>> G(a+b+2);
   REP(i, m) {
      int x, y; cin >> x >> y;
      add_edge(G, x, y+a, 1);
   }
   REP(x, a) {
      add_edge(G, a+b, x, 1);
   }
   REP(y, b) {
      add_edge(G, y+a, a+b+1, 1);
   }
   int ans = max_flow(G, a+b, a+b+1);
   cout << ans << endl;

   return 0;
}



Measured memory_bytes: 3284