```python
import math

def max_profit(price, k):
    """
    Finds the maximum profit earned from a maximum of k stock transactions.

    Args:
        price: A list of stock prices for consecutive days.
        k: The maximum number of transactions allowed.

    Returns:
        The maximum profit that can be achieved.
    """
    n = len(price)
    if n < 2 or k == 0:
        return 0

    # If k is large enough, it's equivalent to unlimited transactions.
    # The maximum number of non-overlapping transactions is n // 2.
    if k >= n // 2:
        profit = 0
        for i in range(1, n):
            if price[i] > price[i - 1]:
                profit += price[i] - price[i - 1]
        return profit

    # dp_hold[j]: max profit after j transactions, currently holding a stock.
    # dp_not_hold[j]: max profit after j transactions, not holding a stock.
    # A transaction is a buy-sell pair. Buying initiates the j-th transaction.
    
    # Initialize dp arrays.
    # dp_hold is initialized to -inf because we start with no money and no stock.
    # dp_not_hold[0] is 0 (0 profit with 0 transactions), others are -inf.
    dp_hold = [-math.inf] * (k + 1)
    dp_not_hold = [0] + [-math.inf] * k

    for p in price:
        # Iterate backwards to use values from the previous day (before they are updated).
        # This is because dp_hold[j] depends on dp_not_hold[j-1] from the previous day.
        for j in range(k, 0, -1):
            # Max profit if we are not holding stock after today:
            # 1. We were not holding yesterday and did nothing today. (dp_not_hold[j])
            # 2. We were holding yesterday and sold today. (dp_hold[j] + p)
            dp_not_hold[j] = max(dp_not_hold[j], dp_hold[j] + p)
            
            # Max profit if we are holding stock after today:
            # 1. We were holding yesterday and did nothing today. (dp_hold[j])
            # 2. We were not holding yesterday (after j-1 transactions) and bought today. (dp_not_hold[j-1] - p)
            dp_hold[j] = max(dp_hold[j], dp_not_hold[j-1] - p)

    # The result is the maximum profit possible with at most k transactions,
    # ending in a state of not holding a stock.
    # This includes 0 transactions (profit 0) up to k transactions.
    # Since dp_not_hold[0] is always 0, the result will be non-negative.
    return int(max(dp_not_hold))
```