
    Design an algorithm to calculate the number of distinct ways to construct an investment portfolio using n different asset classes, where exactly m asset classes have a higher expected return than their immediately preceding selection in the portfolio, helping determine optimal risk-adjusted allocation strategies. The result will help quantify the diversity of possible portfolio arrangements that maintain specific risk progression patterns, essential for matching client risk preferences.
    

    
def eulerian_num(n, m):
    """
    Design an algorithm to calculate the number of distinct ways to construct an investment portfolio using n different asset classes, where exactly m asset classes have a higher expected return than their immediately preceding selection in the portfolio, helping determine optimal risk-adjusted allocation strategies. The result will help quantify the diversity of possible portfolio arrangements that maintain specific risk progression patterns, essential for matching client risk preferences.
    

    """
def eulerian_num(n, m):
    """
    Design an algorithm to calculate the number of distinct ways to construct an investment portfolio using n different asset classes, where exactly m asset classes have a higher expected return than their immediately preceding selection in the portfolio, helping determine optimal risk-adjusted allocation strategies. The result will help quantify the diversity of possible portfolio arrangements that maintain specific risk progression patterns, essential for matching client risk preferences.
    

    """
    if m >= n or n == 0:
        return 0
    if m == 0:
        return 1
    return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m)