#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main(){ int N, M, Q, a, b; cin >> N >> M >> Q; set> st; for (int i=0; i> a >> b; st.insert({a, b}); } vector> dp(N+1, vector(M+1)); for (int i=1; i<=N; i++){ for (int j=1; j<=N; j++){ dp[i][j] = max(dp[i-1][j], dp[i][j-1]); if (st.count({i, j})) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1); } } cout << dp[N][M] << endl; return 0; }