def rec_matrix_shape(matrix, shape):
    """
    Recursive function to calculate the shape of a Matrix
    Returns the shape as a list of integers
    """
    if type(matrix) == list:
        shape.append(len(matrix))
        rec_matrix_shape(matrix[0], shape)
    return shape