import java.util.*;

public class Solution 
{
    public static int overlappingArea(int[] rect1BottomLeft, int[] rect1TopRight, int[] rect2BottomLeft, int[] rect2TopRight) 
    {
        int width;
        int height;
        
        if ((rect1TopRight[1] > rect2TopRight[1]
            &&rect1BottomLeft[1]>rect2BottomLeft[1]))
            
            {
            
                                                         
         width =  Math.abs(0-rect1BottomLeft[0])-Math.abs(0-rect2TopRight[0]);
        System.out.println("WIDTH1: " + width);

        height = Math.abs(0-rect1BottomLeft[1]) - Math.abs(0-rect2TopRight[1]);
        System.out.println("HEIGHT2: " + height);
        

        return (Math.abs(width) * Math.abs(height));
        
    }
        
        else
        {
            if  ((rect2TopRight[1] > rect1TopRight[1]
           &&rect2BottomLeft[1]>rect1BottomLeft[1]))
           {
                  width = Math.abs(0-rect2BottomLeft[0]) - Math.abs(0-rect1TopRight[0]);
        System.out.println("WIDTH: " + width);

        height = Math.abs(0-rect2BottomLeft[1]) - Math.abs(0-rect1TopRight[1]);
        System.out.println("HEIGHT: " + height);
               
           }
           else
           {
            
            System.out.println("NO OVERLAP FOUND");
            return 0;
           }
           
        }
        return (Math.abs(width) * Math.abs(height));
    }

    public static void main (String[] args)
    {
      
        //TEST CASE 1
        //System.out.println("The overlapping area is: " + overlappingArea(new int[]{-5, -4},  new int[]{-2, -1}, new int[]{-4, -2}, new int[]{0, 2}));
        //                                //rect1bottomLeft     //rect1TopRight   //rect2BottomLeft    //rect2TopRight
        
        //TEST CASE 2 - same as above, but it will flip coordinates of the two rectangles
        //System.out.println("The overlapping area is: " + overlappingArea(new int[]{-4, -2}, new int[]{0, 2},new int[]{-5, -4}, new int[]{-2, -1}));
        //                                //rect1bottomLeft     //rect1TopRight   //rect2BottomLeft    //rect2TopRight
                        
        //TEST CASE 3
        //System.out.println("The overlapping area is: " + overlappingArea(new int[]{-6, -5},  new int[]{-4, -3}, new int[]{-5, -4}, new int[]{-3, -1}));
        //                                //rect1bottomLeft     //rect1TopRight   //rect2BottomLeft    //rect2TopRight
        
          //TEST CASE 4
        System.out.println("The overlapping area is: " + overlappingArea(new int[]{-5, -4}, new int[]{-3, -1},new int[]{-6, -5},  new int[]{-4, -3});
        //                                //rect1bottomLeft     //rect1TopRight   //rect2BottomLeft    //rect2TopRight
        
    }
}