Making Anagrams
InterviewTime limit2sMemory limit128 MB
Given two lowercase words, compute how many letters must be deleted in total so their remaining letters match as multisets (anagrams).
Problem
Two English words are anagrams if their letters can be rearranged to become the same word. For example, occurs and succor are anagrams because rearranging the letters of occurs can make succor.
The words dared and bread are not anagrams as written. If one d is removed from dared and one b is removed from bread, the remaining words ared and read are anagrams.
Given two English words, find the minimum number of letters that must be removed so the two words can become anagrams. A removed letter may be at any position.
Input
The first and second lines each contain one lowercase English word. Each word has length from 1 to 1,000.
Output
Print one line containing the minimum number of letters that must be removed.