#include <vector>
#include <iostream>
using namespace std;

class FordFulkerson {
public:
  struct Edge { int to, cap, rev; };

  FordFulkerson(int V, int S, int T): V(V), S(S), T(T), G(V, vector<Edge>(0)), used(V, false) {}

  void addEdge(int from, int to, int cap) {
    G[from].push_back({ to, cap, (int)G[to].size() });
    G[to].push_back({ from, 0, (int)G[from].size()-1 });
  }

  int maxFlow() {
    int flow = 0;
    for (;;) {
      resetUsed();
      int f = dfs(S, INFTY);
      if (f == 0) return flow;
      flow += f;
    }
  }

private:
  const int INFTY = (1 << 21);
  int V, S, T;
  vector<vector<Edge> > G;
  vector<bool> used;

  int dfs(int v, int f) {
    if (v == T) return f;
    used.at(v) = true;
    for (auto &edge: G.at(v)) {
      if (used.at(edge.to)) continue;
      if (edge.cap <= 0) continue;
      int d = dfs(edge.to, min(f, edge.cap));
      if (d <= 0) continue;
      edge.cap -= d;
      G.at(edge.to).at(edge.rev).cap += d;
      return d;
    }

    return 0;
  }

  void resetUsed() {
    fill(used.begin(), used.end(), false);
  }
};

#define MAX_E 10001
int X, Y, E, SS[MAX_E], TS[MAX_E];

void input() {
  cin >> X >> Y >> E;
  for (int e=0;e<E;e++) {
    cin >> SS[e] >> TS[e];
  }
}

void solve() {
  int S = X + Y, T = X + Y + 1, V = T + 1;
  FordFulkerson ff(V, S, T);
  for (int e=0;e<E;e++) ff.addEdge(SS[e], TS[e]+X, 1);
  for (int x=0;x<X;x++) ff.addEdge(S, x, 1);
  for (int y=0;y<Y;y++) ff.addEdge(y+X, T, 1);
  cout << ff.maxFlow() << endl;
}

int main() {
  input();
  solve();
  return 0;
}


