def viralAdvertising(n):
    # Write your code here
    cum = 0
    
    shared = 5
    for i in range(n):
        liked = shared // 2
        cum += liked
        
        shared = liked * 3
        
    return cum
def beautifulDays(i, j, k):
    # Write your code here
    cnt = 0
    for n in range(i, j + 1):
        rn = int(str(n)[::-1])
        diff = (n - rn) % k
        
        if not diff:
            cnt += 1
            
    return cnt
def angryProfessor(k, a):
    # Write your code here
    attend = sum([1 if i <= 0 else 0 for i in a])
    
    return 'NO' if attend >= k else 'YES'
def utopianTree(n):
    # Write your code here
    init_height = 1
    
    for i in range(n):
        if (i + 1) % 2:
            init_height *= 2
        else:
            init_height += 1
            
    return init_height
import string

def designerPdfViewer(h, word):
    # Write your code here
    alphabet_list = list(string.ascii_lowercase)
    
    max_idx = -1
    for i in word:
        if max_idx < h[alphabet_list.index(i)]:
            max_idx = h[alphabet_list.index(i)]
            
    return max_idx * len(word)