```python
def count_Squares(m, n):
    """
    Counts the total number of squares in a rectangle of size m x n.

    The logic is based on the observation that the number of squares is the sum of:
    - Number of 1x1 squares: m * n
    - Number of 2x2 squares: (m-1) * (n-1)
    - Number of 3x3 squares: (m-2) * (n-2)
    ...and so on, until one of the dimensions becomes 1.

    This can be calculated iteratively by summing m * n and then decrementing
    both m and n until one of them reaches zero.
    """
    
    # If either dimension is non-positive, no squares can be formed.
    if m <= 0 or n <= 0:
        return 0

    # The loop will run min(m, n) times.
    # It works correctly regardless of which dimension is larger.
    total_squares = 0
    while m > 0 and n > 0:
        total_squares += m * n
        m -= 1
        n -= 1
        
    return total_squares
```