Make an Anagram

Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem type
Allowed languages
C, C++, Java, Python

Nic tends to confuse people with anagrams, not intentionally, but sometimes he gets his words mixed up. Two strings are anagrams of each other if the letters of the first string can be arranged to form the second string. For example, bad credit and debit card are anagrams.

You, a concerned observer of Nic, wonder how many characters need to be deleted from one of two string Nic has uttered to make them anagrams. Can you compute this number?

More formally, given two string \(A\) and \(B\) of possibly different lengths but comprised of lowercase letters and spaces only, determine the minimum number of character deletions required to make them anagrams. Any characters can be deleted from either of the strings. N.B. Spaces count as separate characters and form part of the anagram.

Input Specification

Two lines. The first contains a single string \(A\). The second contains another string \(B\).

\(1 \leq |A|,|B| \leq 10^4\)

Output Specification

A single integer denoting the number of characters you must delete to make the strings anagrams of each other. You are guaranteed this is possible for all test cases.

Sample Input 1

older and wiser
i learned words

Sample Output 1


Sample Input 2


Sample Output 2



In the second example, we delete the a from potato and s,v,e from stovetop.


There are no comments at the moment.