def score(hand):
    """
    Compute the maximal score for a Yahtzee hand according to the
    upper section of the Yahtzee score card.

    hand: full yahtzee hand, a tuple of dice value

    Returns an integer score 
    """
    
    value = {}
    for ind in range(1, max(hand)+1):
        value[ind] = 0
    
    for ele in hand:
        value[ele] += ele
    val = -1
    for ele in value:
        if value[ele] > val:
            val = value[ele]

    return val