#K40612. Minimum Removals to Make Anagrams

    ID: 26682 Type: Default 1000ms 256MiB

Minimum Removals to Make Anagrams

Minimum Removals to Make Anagrams

You are given two strings A and B. Your task is to determine the minimum number of characters that must be removed from the two strings so that they become anagrams of each other. Two strings are anagrams if the frequency of each character in the two strings is the same.

The number of removals can be computed using the formula:

$$ \text{removals} = \sum_{c \in \{a, \ldots, z\}} \left| \text{freq}_A(c) - \text{freq}_B(c) \right| $$

For example, if A is "cde" and B is "abc", the answer is 4 because you need to remove 'd' and 'e' from the first string and 'a' and 'b' from the second string. Similarly, if one string is already an anagram of the other, then no removals are needed.

inputFormat

The first line contains an integer T representing the number of test cases. For each test case, the input consists of two lines. The first line of each test case contains the string A and the second line contains the string B.

outputFormat

For each test case, output a single integer representing the minimum number of removals required to make the two strings anagrams of each other. Each answer should be printed on its own line.

## sample
2
cde
abc
abcd
efgh
4

8

</p>