#Ameya Rao
#Feb 4 2020
#Intermediate 5
#Enloe
#Potter

filename = "/Volumes/Untitled/2inttest.txt"
#filename = "sampleInt2.txt"

inputs = []
with open(filename) as file_object:
  for line in file_object:
    inputs.append(line.rstrip())
    print(line.rstrip())

def lenOfSmall(first, second):
  if (len(first) >= len(second)):
    loopLen = len(second)
  else:
    loopLen = len(first)
  return loopLen

def deleteStars(word):
  newWord = ""
  for x in range(len(word)):
    if (word[x] != '*'):
      newWord += word[x]
  return newWord

for x in inputs:
  shiftable = True
  posCut = x.find(" ")
  word1 = x[:posCut]
  word2 = x[posCut+1:]
  #print(word1)
  #print(word2) #separating the two strings
  #we want to traverse the shortest string
  loopLen = lenOfSmall(word1, word2)
  while (shiftable):
    #delete any same chars in same pos
    for y in range(loopLen):
      if (word1[y] == word2[y]):
        delete = word1[y]
        word1 = word1[:y] + '*' + word1[y+1:]
        word2 = word2[:y] + '*' + word2[y+1:]
        #print(word1)
        #print(word2)
    word1 = deleteStars(word1)
    word2 = deleteStars(word2)
    #print(word1)
    #print(word2)
    #shifting now
    deleted = False
    loopLen = (lenOfSmall(word1, word2)-1)*2
    if (len(word1) != len(word2)):
      loopLen+=1
    for m in range(loopLen+1):
      if (len(word1) != len(word2)):
        if (len(word1)>len(word2)):
          #word 1 is longest
          if (m == loopLen):
            if(word1[(m+1)//2] == word2[((m+1)//2)-1]):
              word1 = word1[:((m+1)//2)-1] + '*' + word1[((m+1)//2):]
              #print(word1)
              deleted = True
              break
        else:
          #word 2 is the longest
          if (m == loopLen):
            if(word2[(m+1)//2] == word1[((m+1)//2)-1]):
              word2 = word2[:((m+1)//2)-1] + '*' + word2[((m+1)//2):]
              #print(word2)
              deleted = True
              break
      if (m%2 == 1 and m!=loopLen):
        #check second string is first string-1
        if (word2[(m+1)//2] == word1[((m+1)//2)-1]):
          word2 = word2[:((m+1)//2)-1] + '*' + word2[((m+1)//2):]
          #print(word2)
          deleted = True
          break
      elif (m%2 == 0 and m!= 0):
        #check first string is second string-1
        if (word1[m//2] == word2[(m//2)-1]):
            word1 = word1[:(m//2)-1] + '*' + word1[(m//2):]
            #print(word1)
            deleted = True
            break
    word1 = deleteStars(word1)
    word2 = deleteStars(word2)
    #if nothing was able to shift, now ur done so exit while loop
    if (not deleted):
      shiftable = False
    else: 
      loopLen = lenOfSmall(word1, word2)
  #now doing the number subtracting thing
  if (len(word1) >= len(word2)):
      loopLen = len(word2)
  else:
    loopLen = len(word1)
  sum = 0
  for m in range(loopLen):
    sum = sum - (ord(word2[m])-ord(word1[m]))
  if (len(word1) != len(word2)):
    if (len(word1) > len(word2)):
      sum = sum + (len(word1)-len(word2))
    else:
      sum = sum + (len(word2)-len(word1))
  print(sum)