#include<algorithm> using namespace std; long long f(long long x1, long long x2, long long y1, long long y2) { if(x1 < y1) { if(y1 >= x2) return 0; else{ if(y2 >= x2) return x2 - y1; else return y2 - y1; } } else { if(x1 >= y2) return 0; else{ if(x2 >= y2) return y2 - x1; else { return x2 - x1; } } } } int main() { long long x[4],y[4]; for(int i = 0; i < 4; i++) scanf("%lld%lld", &x[i], &y[i]); long long X = f(x[0],x[1],x[2],x[3]); long long Y = f(y[0],y[1],y[2],y[3]); long long ans = (x[1] - x[0])* (y[1] - y[0]) + (x[3] - x[2])* (y[3] - y[2]) - X*Y; printf("%lld\n", ans); }