def grubler(L,J1,J2):
    """
    Calculates the DOF of a linkage using Grübler-Kutzbach criterion
    
    Parameters
    ----------
    L : int
        Number of links
    J1 : int
        1-DOF pairs
    J2 : int
        2-DOF pairs
        
    Returns
    -------
    M : int
        Degrees of freedom
    """
    M = 3*(L-1) - 2*J1 - J2
    return M