Cutting Lines

No attempts yetTime limit3sMemory limit256 MB

Problem

A rectangle has corners (0,0)(0,0), (W,0)(W,0), (0,H)(0,H), and (W,H)(W,H). There are NN cut segments, each parallel to a side. Segment ii runs from (Ai,Bi)(A_i,B_i) to (Ci,Di)(C_i,D_i) with exactly one of Ai=CiA_i=C_i or Bi=DiB_i=D_i. Parallel segments never share a point, and no parallel segment touches the paper border. After cutting along every segment, how many pieces remain?

Input

The first line has WW, HH, and NN. The next NN lines give each segment's endpoints.

Output

Print the number of pieces on one line.

Limits

1W,H1091 \le W,H \le 10^9, 1N1051 \le N \le 10^5.