# A.J. Kim
# Bergen County Academies
# Intermediate

def maybe_shift(beep, boop):

    i = 0


    if (len(beep) < len(boop)):



    
        while (i < len(beep)):
            if (i > 0) and (beep[i] == boop[i - 1]):
                beep = beep[0:i-1] + beep[i+1:]
                break

            elif beep[i] == boop[i+1]:
                boop = boop[0:i] + boop[i+1:]
                break
            

            elif (i < len(beep) - 1) and (beep[i + 1] == boop[i]):
                beep = beep[0:i] + beep[i+1:]
                break

            i+=1


    
    elif (len(boop) < len(beep)):
        while (i < len(boop)):
            if (i > 0) and (boop[i] == beep[i - 1]):
                boop = boop[0:i-1] + boop[i+1:]
                break

            elif boop[i] == beep[i+1]:
                beep = beep[0:i] + beep[i+1:]
                break
    

            elif (i < len(boop) - 1) and (boop[i + 1] == beep[i]):
                boop = boop[0:i] + boop[i+1:]
                break

            i += 1



    else:
        while (i < len(beep) - 1):
            if (beep[i] == boop[i + 1]):
                boop = boop[0:i] + boop[i+1:]
                break
            elif (boop[i] == beep[i + 1]):
                beep = beep[0:i] + beep[i+1:]
                break
            i += 1
    


    return [beep, boop]    



def deleting_chars(beep, boop):
    
  changed = False
  
  if len(beep) > len(boop):
      changed = True
      temp = beep
      beep = boop
      boop = temp

  i = 0
  
  while i < len(beep):
       
      while (i < len(beep)) and i < len(boop) and (beep[i] == boop[i]):
        beep = beep[0:i] + beep[i+1:]
        boop = boop[0:i] + boop[i+1:]

      i+=1
      

  if changed:
      return [boop, beep]

  return [beep, boop]



def prepare(beep, boop):
    smallest_len = len(beep)
    if(len(beep) > len(boop)):
        smallest_len = len(boop)

    i = 0
    while i < smallest_len - 1:
        news = deleting_chars(beep, boop)
        beep = news[0]
        boop = news[1]

        
        
        news = maybe_shift(beep, boop)
        beep = news[0]
        boop = news[1]


        i += 1

    return [beep, boop]






def asf(beep, boop):


    length = len(beep)
    if len(beep) > len(boop):
        length = len(boop)

    totalScore = 0
    
    i = 0
    while (i < length):

        one = ord(beep[i]) - 64
        two = ord(boop[i]) - 64


        totalScore += (one - two)


        i += 1

    leftover = abs(len(boop) - len(beep))
    totalScore += leftover
    

    return totalScore



def main():
    fp = open("2int_sampledata.txt", 'r')
    while True:

        try:
            line = fp.readline().upper()
            
            if not line:
                break
            
            ins = line.strip().split(" ")

            prepared = prepare(ins[0], ins[1])
            print(asf(prepared[0], prepared[1]))

        except:
            print("\n")

    



main()