import bisect import sys readline=sys.stdin.readline def LIS(lst,weakly=False,max_value=float('inf')): f=bisect.bisect_right if weakly else bisect.bisect_left N=len(lst) update=[None]*N dp=[max_value]*N for k,x in enumerate(lst): i=f(dp,x) dp[i]=x update[k]=(i,dp[i]) n=bisect.bisect_left(dp,max_value) lis=[None]*n n-=1 for i,x in update[::-1]: if i==n: lis[n]=x n-=1 return lis N,M,Q=map(int,readline().split()) AB=[] for _ in range(Q): a,b=map(int,readline().split()) AB.append((a,b)) AB.sort(key=lambda tpl:(tpl[0],-tpl[1])) B=[b for a,b in AB] inf=1<<60 ans=len(LIS(B,max_value=inf)) print(ans)