```
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int res = calculate(A,B,C,D) + calculate(E,F,G,H);
return res - calculate(Math.max(A,E),Math.max(B,F),Math.min(C,G),Math.min(D,H));
}
private int calculate(int a,int b,int c,int d) {
if(a >= c || b >= d) return 0;
return (c - a) * (d - b);
}
```