```python
import math

def get_Min_Squares(n):
    """
    Finds the minimum number of squares whose sum is equal to a given number n.
    This solution is based on Lagrange's four-square theorem and Legendre's three-square theorem.
    """
    if n <= 0:
        return 0

    # Case 1: If n is a perfect square, the answer is 1.
    sqrt_n = int(math.sqrt(n))
    if sqrt_n * sqrt_n == n:
        return 1

    # Case 4: If n is of the form 4^k * (8m + 7), the answer is 4.
    # This is a result of Legendre's three-square theorem.
    temp_n = n
    while temp_n % 4 == 0:
        temp_n //= 4
    if temp_n % 8 == 7:
        return 4

    # Case 2: If n is the sum of two squares, the answer is 2.
    for i in range(1, int(math.sqrt(n)) + 1):
        remainder = n - i * i
        sqrt_remainder = int(math.sqrt(remainder))
        if sqrt_remainder * sqrt_remainder == remainder:
            return 2

    # Case 3: If the number is not a sum of 1, 2, or 4 squares, it must be a sum of 3 squares.
    return 3
```