We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency. For example, bacdc and dcbac are anagrams, but bacdc and dcbad are not.

Alice is taking a cryptography class and finding anagrams to be very useful. She decides on an encryption scheme involving two large strings where encryption is dependent on the minimum number of character deletions required to make the two strings anagrams. Can you help her find this number? 

Given two strings, $\mbox{s1}$ and $\mbox{s2}$, that may not be of the same length, determine the minimum number of character deletions required to make $\mbox{s1}$ and $\mbox{s2}$ anagrams. Any characters can be deleted from either of the strings. 

Example. 

$\textit{s1}=\texttt{abc}$ 

$s2=\textbf{amnop}$     

The only characters that match are the $\mbox{a}$'s so we have to remove $\mathbf{bc}$ from $\mbox{s1}$ and $\textbf{mnop}$ from $\mbox{s2}$ for a total of $\boldsymbol{6}$ deletions.  

Function Description  

Complete the makingAnagrams function in the editor below.    

makingAnagrams has the following parameter(s):  

string s1: a string  
string s2: a string   

Returns   

int: the minimum number of deletions needed   

Input Format

The first line contains a single string, $\mbox{s1}$. 

The second line contains a single string, $\mbox{s2}$.

Constraints

$1\leq|s1|,|s2|\leq10^4$  
It is guaranteed that $\mbox{s1}$ and $\mbox{s2}$ consist of lowercase English letters, ascii[a-z].

Sample Input
cde
abc

Sample Output
4

Explanation

Delete the following characters from our two strings to turn them into anagrams:

Remove d and e from cde to get c.
Remove a and b from abc to get c.

$4$ characters have to be deleted to make both strings anagrams.

Difficulty: EASY
Tags: String algorithms

Starter code:

Solutions:
import sys
lines = [sys.stdin.readline(), sys.stdin.readline()]
lines = [line.strip() for line in lines]
lines = [sorted(line) for line in lines]
counts = [[sum([1 for c in line if c == test]) for test in 'abcdefghijklmnopqrstuvwxyz'] for line in lines]
diffs = [abs(counts[0][i] - counts[1][i]) for i in range(len(counts[0]))]
print(sum(diffs))


import collections, sys
A = sys.stdin.readline().strip()
B = sys.stdin.readline().strip()
a = collections.Counter(A)
b = collections.Counter(B)
length = sum((min(a[c], b[c]) for c in set(A) & set(B)))
print(len(A) - length + (len(B) - length))


import sys
from functools import *
a = sys.stdin.readline()
b = sys.stdin.readline()
x = {}

def f(w, cf=1):
	for c in w:
		if c not in 'abcdefghijklmnopqrstuvwxyz':
			continue
		if c not in x:
			x[c] = 0
		x[c] += cf
f(a)
f(b, -1)
res = reduce(lambda a, b: a + abs(x[b]), x.keys(), 0)
print(res)


s = input()
t = input()
ls = len(s)
lt = len(t)
c = 0
if ls <= lt:
	for i in list(s):
		j = t.find(i)
		if j != -1:
			t = t.replace(i, '', 1)
		else:
			c += 1
else:
	for i in list(t):
		j = s.find(i)
		if j != -1:
			s = s.replace(i, '', 1)
		else:
			c += 1
c += len(t)
print(c)


a = input()
b = input()
l1 = list(a)
l2 = list(b)
d1 = dict()
d2 = dict()
for x in l1:
	if d1.get(x) == None:
		d1[x] = 1
	else:
		d1[x] += 1
for x in l2:
	if d2.get(x) == None:
		d2[x] = 1
	else:
		d2[x] += 1
mindel = 0
for i in range(97, 123):
	if d1.get(chr(i)) == None and d2.get(chr(i)) == None:
		continue
	elif d1.get(chr(i)) == None:
		mindel += d2.get(chr(i))
	elif d2.get(chr(i)) == None:
		mindel += d1.get(chr(i))
	elif d1.get(chr(i)) < d2.get(chr(i)):
		mindel += d2.get(chr(i)) - d1.get(chr(i))
	else:
		mindel += d1.get(chr(i)) - d2.get(chr(i))
print(mindel)


def make_char_count(char_count, str_word, inc):
	for c in str_word:
		if c in char_count:
			char_count[c] += inc
		else:
			char_count[c] = inc

def main():
	A = input().strip()
	B = input().strip()
	char_count = {}
	make_char_count(char_count, A, 1)
	make_char_count(char_count, B, -1)
	print(sum((abs(c) for c in char_count.values())))
main()


leftMap = [0] * 26
rightMap = [0] * 26
leftStr = input()
rightStr = input()
for i in leftStr:
	leftMap[ord(i) - 97] += 1
for i in rightStr:
	rightMap[ord(i) - 97] += 1
ret = 0
for i in range(26):
	ret += abs(leftMap[i] - rightMap[i])
print(ret)


s1 = input()
s2 = input()
s3 = set(s1 + s2)
diff = 0
for i in s3:
	diff += abs(s1.count(i) - s2.count(i))
print(diff)


s1 = input()
s2 = input()
q = []
c = 0
p = ''
for i in s1:
	if i in s2 and i not in p:
		c = c + min(s1.count(i, 0, len(s1)), s2.count(i, 0, len(s2)))
		p = p + i
print(len(s1) - c + len(s2) - c)


str1 = input()
str2 = input()
a = [0 for i in range(0, 27)]
for i in str1:
	a[ord(i) - ord('a')] += 1
for i in str2:
	a[ord(i) - ord('a')] -= 1
ans = 0
for i in a:
	if i < 0:
		ans += -i
	else:
		ans += i
print(ans)


a = input()
b = input()
al = {}
bl = {}
for ch in a:
	al[ch] = al.get(ch, 0) + 1
for ch in b:
	bl[ch] = bl.get(ch, 0) + 1
for ch in al.keys():
	bl[ch] = bl.get(ch, 0)
for ch in bl.keys():
	al[ch] = al.get(ch, 0)
print(sum([abs(al[ch] - bl[ch]) for ch in al.keys()]))


str1 = input()
str2 = input()
characters = list(set(str1 + str2))
changes = 0
for char in characters:
	changes += abs(str1.count(char) - str2.count(char))
print(changes)


str1 = input().strip()
str2 = input().strip()
freqs = {}
diffs = 0
for s in str1:
	freqs[s] = freqs.get(s, 0) + 1
for s in str2:
	if s in freqs:
		freqs[s] -= 1
		if freqs[s] == 0:
			del freqs[s]
	else:
		diffs += 1
print(diffs + sum(freqs.values()))


a = list(input())
b = list(input())
to_remove = len(a) + len(b)
for q in range(2):
	for i in range(len(a)):
		if a[i] == -1:
			continue
		try:
			to_replace = b.index(a[i])
			b = b[:to_replace] + [-1] + b[to_replace + 1:]
			to_remove -= 1
			a = a[:i] + [-1] + a[i + 1:]
			to_remove -= 1
		except:
			pass
	(a, b) = [b, a]
print(to_remove)


l1 = input()
l2 = input()
chrs1 = {}
chrs2 = {}
for c in l1:
	if c in chrs1:
		chrs1[c] += 1
	else:
		chrs1[c] = 1
for c in l2:
	if c in chrs2:
		chrs2[c] += 1
	else:
		chrs2[c] = 1
d = 0
for c in chrs1.keys():
	if c in chrs2:
		d += abs(chrs1[c] - chrs2[c])
	else:
		d += chrs1[c]
for c in chrs2.keys():
	if not c in chrs1:
		d += chrs2[c]
print(d)


s1 = input().strip()
s2 = input().strip()
d1 = {}
d2 = {}
for i in s1:
	try:
		d1[i] += 1
	except KeyError:
		d1[i] = 1
for j in s2:
	try:
		d2[j] += 1
	except KeyError:
		d2[j] = 1
ans = 0
for k in d1.keys():
	try:
		ans += max(d1[k], d2[k]) - min(d1[k], d2[k])
		del d2[k]
	except KeyError:
		ans += d1[k]
for k in d2.keys():
	ans += d2[k]
print(ans)


from string import ascii_lowercase
KEYS = dict(map(lambda x: x[::-1], enumerate(ascii_lowercase)))
total = [0 for x in range(26)]
for char in input().strip():
	total[KEYS[char]] += 1
for char in input().strip():
	total[KEYS[char]] -= 1
print(sum(map(abs, total)))


from collections import OrderedDict
dict_a = {}
dict_b = {}
used_keys = []
deletions = 0
str_a = list(input())
str_b = list(input())
for char in str_a:
	if char in dict_a:
		dict_a[char] += 1
	else:
		dict_a[char] = 1
for char in str_b:
	if char in dict_b:
		dict_b[char] += 1
	else:
		dict_b[char] = 1
for char in dict_a:
	if char in dict_b:
		if dict_a[char] > dict_b[char]:
			deletions += dict_a[char] - dict_b[char]
		elif dict_a[char] < dict_b[char]:
			deletions += dict_b[char] - dict_a[char]
	else:
		deletions += dict_a[char]
	used_keys.append(char)
for char in used_keys:
	del dict_a[char]
	if char in dict_b:
		del dict_b[char]
for char in dict_b:
	deletions += dict_b[char]
print(deletions)


import sys

def getDict(wl):
	d = {}
	for w in wl:
		try:
			d[w] += 1
		except KeyError:
			d[w] = 1
	return d

def ana(word1, word2):
	w1 = list(word1)
	w2 = list(word2)
	d1 = getDict(w1)
	d2 = getDict(w2)
	no = 0
	for d in d1:
		try:
			if d1[d] == d2[d]:
				continue
			else:
				no += abs(d1[d] - d2[d])
		except KeyError:
			no += d1[d]
	for d in d2:
		try:
			a = d1[d]
		except KeyError:
			no += d2[d]
	print(no)
data = sys.stdin.readlines()
word1 = data[0].rstrip()
word2 = data[1].rstrip()
ana(word1, word2)


from collections import Counter as mset

def intersections(iter1, iter2):
	return list_from_mset(mset(iter1) & mset(iter2))

def list_from_mset(set1):
	msetlist = []
	for element in set1:
		for i in range(set1[element]):
			msetlist.append(element)
	return msetlist

def base_anagram(string1, string2):
	return ''.join(intersections(string1, string2))

def difference_from_base(string1, string2):
	base_anag = base_anagram(string1, string2)
	diff1 = mset(string1) - mset(base_anag)
	diff2 = mset(string2) - mset(base_anag)
	return msetlength(diff1) + msetlength(diff2)

def msetlength(multiset):
	return len(list_from_mset(multiset))
print(difference_from_base(input(), input()))


import fileinput
import string
string1 = input().lower()
string2 = input().lower()
total = 0
allLetters = string.ascii_lowercase

def compare(s, t, l):
	a = s.count(l)
	b = t.count(l)
	dif = a - b
	if dif < 0:
		dif *= -1
	return dif
for i in range(0, len(allLetters)):
	temp = compare(string1, string2, allLetters[i])
	total += temp
print(total)


cnt = [0 for i in range(128)]
for c in input():
	cnt[ord(c)] += 1
for c in input():
	cnt[ord(c)] -= 1
print(sum([abs(x) for x in cnt]))


first = input()
second = input()
from collections import Counter
fc = Counter(first.strip())
sc = Counter(second.strip())
deletes = 0
alphabet = [chr(x) for x in range(97, 123)]
for letter in alphabet:
	deletes += abs(fc.get(letter, 0) - sc.get(letter, 0))
print(deletes)


from collections import Counter
a = input().strip()
b = input().strip()
c1 = Counter(a)
c2 = Counter(b)
c3 = c1 & c2
x = c1 - c3
y = c2 - c3
z = x + y
n = sum((z[i] for i in z))
print(n)


import string

def line2dict(l):
	r = dict.fromkeys(string.ascii_lowercase, 0)
	for ch in l:
		r[ch] += 1
	return r
lc1 = line2dict(input())
lc2 = line2dict(input())
r = 0
for ch in string.ascii_lowercase:
	r += abs(lc1[ch] - lc2[ch])
print(r)


from collections import Counter
a = input()
b = input()
print(len(a) + len(b) - 2 * sum((Counter(a) & Counter(b)).values()))


def common_chars(a, b):
	common = []
	for char in a:
		if char in b:
			common.append(char)
			b.pop(b.index(char))
	return common
a = list(input())
b = list(input())
print(len(a) + len(b) - 2 * len(common_chars(a, b)))


def frequency_dictionary(s):
	d = dict()
	for c in s:
		if c not in d:
			d[c] = 1
		else:
			d[c] += 1
	return d
a = frequency_dictionary(input())
b = frequency_dictionary(input())
d = 0
for c in a:
	if c in b:
		d += abs(a[c] - b[c])
	else:
		d += a[c]
for c in b:
	if c not in a:
		d += b[c]
print(d)


a = list(input())
b = list(input())
ac = {}
bc = {}
for c in a:
	try:
		ac[c] += 1
	except KeyError:
		ac[c] = 1
for c in b:
	try:
		bc[c] += 1
	except KeyError:
		bc[c] = 1
allChar = set(list(ac.keys()) + list(bc.keys()))
output = 0
for c in allChar:
	aval = 0
	bval = 0
	try:
		aval = ac[c]
	except KeyError:
		aval = 0
	try:
		bval = bc[c]
	except KeyError:
		bval = 0
	output += abs(aval - bval)
print(output)


s = input()
t = input()
ans = 0
for x in range(ord('a'), ord('z') + 1):
	ans = ans + min(s.count(chr(x)), t.count(chr(x)))
print(len(s) + len(t) - 2 * ans)


a = input()
b = input()
t = 0
count1 = [0 for i in range(26)]
count2 = [0 for i in range(26)]
for i in a:
	count1[ord(i) - 97] += 1
for i in b:
	count2[ord(i) - 97] += 1
r = 0
for i in range(26):
	r += abs(count1[i] - count2[i])
print(r)


from timeit import timeit
import sys

def count(anagram):
	l = [0] * 26
	for c in anagram:
		char = ord(c) - 97
		if char >= 0 and char <= 26:
			l[ord(c) - 97] += 1
	return l
(first, second) = (count(sys.stdin.readline()), count(sys.stdin.readline()))
print(sum([abs(f - s) for (f, s) in zip(first, second)]))


cnt = [0] * 26
str1 = input()
str2 = input()
for c in str1:
	cnt[ord(c) - ord('a')] += 1
for c in str2:
	cnt[ord(c) - ord('a')] -= 1
sum = 0
for i in range(26):
	sum += abs(cnt[i])
print(sum)


str1 = input()
str2 = input()
histogram = {}
for ch in str1:
	if histogram.get(ch) == None:
		histogram[ch] = 1
	else:
		val = histogram[ch]
		histogram[ch] = val + 1
for ch in str2:
	if histogram.get(ch) == None:
		histogram[ch] = -1
	else:
		val = histogram[ch]
		histogram[ch] = val - 1
del_ch = 0
for key in histogram.keys():
	if histogram[key] != 0:
		if histogram[key] > 0:
			del_ch += histogram[key]
		else:
			del_ch -= histogram[key]
print(del_ch)


d1 = dict()
d2 = dict()
s1 = input()
s2 = input()
for c in s1:
	if c in d1:
		d1[c] += 1
	else:
		d1[c] = 1
for c in s2:
	if c in d2:
		d2[c] += 1
	else:
		d2[c] = 1
count = 0
for (c, v) in d1.items():
	if c in d2:
		count += abs(d1[c] - d2[c])
		d2[c] = 0
	else:
		count += d1[c]
for (c, v) in d2.items():
	if v:
		count += v
print(count)


from collections import deque

def make_anagrams(f, s):
	(w1, w2) = (deque(sorted(f)), deque(sorted(s)))
	counter = 0
	i = 0
	while w1 and w2:
		if w1[0] == w2[0]:
			w1.popleft()
			w2.popleft()
			continue
		elif w1[0] < w2[0]:
			w1.popleft()
		else:
			w2.popleft()
		counter += 1
	counter += len(w1) + len(w2)
	print(counter)
first = input()
second = input()
make_anagrams(first, second)


import sys, string
dict_A = {a: 0 for a in string.ascii_lowercase}
dict_B = {a: 0 for a in string.ascii_lowercase}
A = sys.stdin.readline().rstrip('\n')
B = sys.stdin.readline().rstrip('\n')
for letter in string.ascii_lowercase:
	dict_A[letter] = A.count(letter)
	dict_B[letter] = B.count(letter)
sum = 0
for letter in string.ascii_lowercase:
	sum += abs(dict_A[letter] - dict_B[letter])
print(sum)


i1 = input()
i2 = input()
letters = 'qwertyuiopasdfghjklzxcvbnm'
c = 0
for l in letters:
	c += abs(i1.count(l) - i2.count(l))
print(c)


a = input()
b = input()
b = list(b)
n = 0
for c in a:
	if c in b:
		n += 1
		b.remove(c)
print(len(a) + len(b) - n)


import sys, string, math

def char_set(str):
	l = [0] * 26
	for i in range(0, len(str)):
		l[ord(str[i]) - 97] += 1
	return l
[a, b] = [input(), input()]
la = char_set(a)
lb = char_set(b)
res = 0
for i in range(0, 26):
	res += int(math.fabs(la[i] - lb[i]))
print(res)


import sys
a = {}
b = {}
for c in sys.stdin.readline().rstrip('\n'):
	a.setdefault(c, 0)
	a[c] += 1
for c in sys.stdin.readline().rstrip('\n'):
	b.setdefault(c, 0)
	b[c] += 1
x = set(list(a.keys()) + list(b.keys()))
n = 0
for c in x:
	n += abs(a.get(c, 0) - b.get(c, 0))
print(n)


s1 = input().strip()
s2 = input().strip()
deleted = 0
for c in s1:
	if c in s2:
		s2 = s2.replace(c, '', 1)
	else:
		deleted += 1
deleted += len(s2)
print(deleted)


s1 = input()
s2 = input()

def getchars(s):
	v = [0] * 26
	for c in s:
		v[ord(c) - 97] += 1
	return v
v1 = getchars(s1)
v2 = getchars(s2)
diff = 0
for i in range(0, 26):
	diff += abs(v1[i] - v2[i])
print(diff)


def toNum(a):
	return ord(a) - ord('a')
str1 = [toNum(a) for a in input()]
str2 = [toNum(a) for a in input()]
arr = [0 for i in range(26)]
for x in str1:
	arr[x] += 1
for x in str2:
	arr[x] = arr[x] - 1
print(sum((abs(x) for x in arr)))


from collections import Counter
ls1 = str(input())
ls1 = list(ls1)
lst1 = Counter(ls1)
ls2 = str(input())
ls2 = list(ls2)
lst2 = Counter(ls2)
n1 = list((lst1 - lst2).elements())
n2 = list((lst2 - lst1).elements())
print(len(n1) + len(n2))


la = [0 for i in range(0, 36)]
lb = [0 for i in range(0, 36)]
a = input()
b = input()
for i in a:
	x = ord(i)
	if x >= 97 and x <= 122:
		la[x - 97] += 1
	else:
		la[x - 48 + 26] += 1
for i in b:
	x = ord(i)
	if x >= 97 and x <= 122:
		lb[x - 97] += 1
	else:
		lb[x - 48 + 26] += 1
re = 0
for i in range(0, 36):
	de = la[i] - lb[i]
	if de < 0:
		de = -de
	re += de
print(re)


from collections import Counter
A = Counter(input())
B = Counter(input())
x = 0
for (k, v) in A.items():
	x += abs(v - B[k])
	del B[k]
for (k, v) in B.items():
	x += abs(v - A[k])
print(x)


s1 = list(input())
s2 = list(input())
c = 0
for i in s1:
	if i in s2:
		c += 1
		s2.remove(i)
print(len(s1) + len(s2) - c)


import sys

def process(str1, str2):
	checker = {}
	for c in str1:
		if c in checker:
			checker[c] += 1
		else:
			checker[c] = 1
	checker1 = {}
	for c in str2:
		if c in checker:
			checker[c] -= 1
			if checker[c] == 0:
				del checker[c]
		elif c in checker1:
			checker1[c] += 1
		else:
			checker1[c] = 1
	return sum([v for (k, v) in checker.items()]) + sum((v for (k, v) in checker1.items()))
str1 = sys.stdin.readline().rstrip()
str2 = sys.stdin.readline().rstrip()
print(process(str1, str2))


from collections import *
a = Counter(input())
b = Counter(input())
c = a - b
d = b - a
e = c + d
print(len(list(e.elements())))


(a, b) = (input(), input())
if len(a) > len(b):
	(a, b) = (b, a)
lb = len(b)
b = [l for l in b]
d = 0
for l in a:
	try:
		del b[b.index(l)]
	except ValueError:
		d += 1
print(d * 2 + lb - len(a))


import sys
import string

def make_dict():
	s = sys.stdin.readline().strip()
	d = dict(zip(string.ascii_lowercase, [0] * len(string.ascii_lowercase)))
	for c in s:
		d[c] += 1
	return d
a = make_dict()
b = make_dict()
res = 0
for c in string.ascii_lowercase:
	res += abs(a[c] - b[c])
print(res)


def make_anagram():
	word_1 = input()
	word_2 = input()
	letter_count = [0] * 26
	num_changes = 0
	for i in word_1:
		letter_count[ord(i) - 97] += 1
	for j in word_2:
		letter_count[ord(j) - 97] -= 1
	for k in range(26):
		if letter_count[k] != 0:
			num_changes += abs(letter_count[k])
	print(num_changes)
make_anagram()


def main():
	string1 = list(input())
	string2 = list(input())
	string1.sort()
	string2.sort()
	list1 = []
	list2 = []
	count = 0
	char = 'a'
	while len(string1) > 0:
		letr = string1[0]
		if letr == char:
			count += 1
			string1.pop(0)
		else:
			list1.append(count)
			count = 0
			char = chr(ord(char) + 1)
	list1.append(count)
	while len(list1) < 26:
		list1.append(0)
	count = 0
	char = 'a'
	while len(string2) > 0:
		letr = string2[0]
		if letr == char:
			count += 1
			string2.pop(0)
		else:
			list2.append(count)
			count = 0
			char = chr(ord(char) + 1)
	list2.append(count)
	while len(list2) < 26:
		list2.append(0)
	final = 0
	for i in range(26):
		final += abs(list1[i] - list2[i])
	print(final)
main()


from collections import Counter
from itertools import chain

def min_delete(line1, line2):
	(c1, c2) = (Counter(line1), Counter(line2))
	intersect = c1 & c2
	result = 0
	for (letter, count) in chain(c1.items(), c2.items()):
		if letter not in intersect:
			result += count
		else:
			result += count - intersect[letter]
	return result
line1 = input()
line2 = input()
print(min_delete(line1, line2))


(a, b, diff, alphabet) = (input(), input(), 0, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])
for element in alphabet:
	tmpa = a.count(element)
	tmpb = b.count(element)
	diff = diff + abs(tmpa - tmpb)
print(str(diff))


__author__ = 'user'

def createMap(string):
	map = {}
	for char in list(string):
		occurences = map.get(char)
		if occurences == None:
			map[char] = 1
		else:
			map[char] = occurences + 1
	return map

def getDeletions(occurences1, occurences2):
	return abs(occurences2 - occurences1)

def getOccurence(key, map):
	occurence = map.get(key)
	if occurence == None:
		occurence = 0
	return occurence

def getDeletionsFromMaps(map1, map2):
	if map1 == {}:
		if map2 == {}:
			return 0
		else:
			key = list(map2.keys())[0]
	else:
		key = list(map1.keys())[0]
	deletions = getDeletions(getOccurence(key, map1), getOccurence(key, map2))
	map1.pop(key, None)
	map2.pop(key, None)
	return deletions + getDeletionsFromMaps(map1, map2)

def getMinDel(string1, string2):
	map1 = createMap(string1)
	map2 = createMap(string2)
	return getDeletionsFromMaps(map1, map2)
string1 = input()
string2 = input()
print(getMinDel(string1, string2))


string1 = input()
string2 = input()
hash_map1 = {}
hash_map2 = {}
for i in string1:
	if i in hash_map1.keys():
		hash_map1[i] += 1
	else:
		hash_map1[i] = 1
for i in string2:
	if i in hash_map2.keys():
		hash_map2[i] += 1
	else:
		hash_map2[i] = 1
comb_list = []
for i in hash_map1.keys():
	comb_list.append(i)
for i in hash_map2.keys():
	if not i in comb_list:
		comb_list.append(i)
count = 0
for i in comb_list:
	if i in hash_map1.keys() and (not i in hash_map2.keys()):
		count += hash_map1[i]
	elif not i in hash_map1.keys() and i in hash_map2.keys():
		count += hash_map2[i]
	elif i in hash_map1.keys() and i in hash_map2.keys():
		count += abs(hash_map1[i] - hash_map2[i])
print(count)


st1 = input()
st2 = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
e1 = 26 * [0]
e2 = 26 * [0]
for char in st1:
	e1[alpha.index(char)] += 1
for char in st2:
	e2[alpha.index(char)] += 1
count = 0
for i in range(26):
	if e1[i] < e2[i]:
		count += e2[i] - e1[i]
	else:
		count += e1[i] - e2[i]
print(count)


tab = {}
change = 0
str1 = input()
for c in str1:
	if c in tab.keys():
		tab[c] += 1
	else:
		tab[c] = 1
str2 = input()
for c in str2:
	if c not in tab.keys():
		change += 1
	else:
		tab[c] -= 1
for c in tab.keys():
	change += abs(tab[c])
print(change)


string1 = input()
string1 = list(string1)
string2 = input()
string2 = list(string2)
count = 0
string3 = set(string1)
string4 = set(string2)
for s in string3:
	if string2.count(s) == 0:
		count += string1.count(s)
	elif string2.count(s) > string1.count(s):
		count += string2.count(s) - string1.count(s)
	elif string1.count(s) > string2.count(s):
		count += string1.count(s) - string2.count(s)
for stringX in string4:
	if string1.count(stringX) == 0:
		count += string2.count(stringX)
print(count)


a = list(input().strip())
b = list(input().strip())
tmp_a = list(a)
delete = []
for element in tmp_a:
	if element in b:
		a.remove(element)
		b.remove(element)
	else:
		delete.append(element)
delete += b
print(len(delete))


s1 = input()
s2 = input()
count = 0
processed = []
for c in s1 + s2:
	if c not in processed:
		count += abs(s1.count(c) - s2.count(c))
		processed.append(c)
print(count)


s1 = input()
s2 = input()
C = {}
for c in s1:
	C[c] = C.get(c, 0) + 1
for c in s2:
	C[c] = C.get(c, 0) - 1
print(sum((abs(C[c]) for c in C)))


sa = input()
sb = input()
sac = [sa.count(i) for i in sa]
sbc = [sb.count(i) for i in sb]
sad = dict(set(zip(sa, sac)))
sbd = dict(set(zip(sb, sbc)))
ssa = set(sa)
ssb = set(sb)
common_chars = set.intersection(ssa, ssb)
del_count = 0
for key_a in sad:
	if key_a not in common_chars:
		del_count += sad[key_a]
	if key_a in sbd and sad[key_a] != sbd[key_a]:
		cmn_diff = abs(sbd[key_a] - sad[key_a])
		del_count += cmn_diff
for key_b in sbd:
	if key_b not in common_chars:
		del_count += sbd[key_b]
print(del_count)


A = input()
B = input()
letters_A = [0] * (ord('z') - ord('a') + 1)
letters_B = [0] * (ord('z') - ord('a') + 1)
ord_a = ord('a')
for letter in A:
	letters_A[ord(letter) - ord_a] += 1
for letter in B:
	letters_B[ord(letter) - ord_a] += 1
diff = 0
for index in range(len(letters_A)):
	diff += abs(letters_A[index] - letters_B[index])
print(diff)


a = str(input())
b = str(input())
aCount = [0] * 26
bCount = [0] * 26
for c in a:
	aCount[ord(c) - 97] += 1
for c in b:
	bCount[ord(c) - 97] += 1
total = 0
for i in range(26):
	total += abs(aCount[i] - bCount[i])
print(total)


from sys import stdin
from collections import Counter
c1 = Counter(stdin.readline().strip())
c2 = Counter(stdin.readline().strip())
c1.subtract(c2)
print(sum(map(abs, c1.values())))


def f(a, b):
	a = sorted(list(a))
	b = sorted(list(b))
	(ai, bi) = (0, 0)
	c = 0
	while True:
		if ai >= len(a) and bi >= len(b):
			return c
		elif ai >= len(a):
			c += 1
			bi += 1
		elif bi >= len(b):
			c += 1
			ai += 1
		elif a[ai] == b[bi]:
			ai += 1
			bi += 1
		elif a[ai] < b[bi]:
			c += 1
			ai += 1
		elif a[ai] > b[bi]:
			c += 1
			bi += 1
print(f(input(), input()))


s1 = input()
s2 = input()
ar1 = [ord(c) - ord('a') for c in s1]
ar2 = [ord(c) - ord('a') for c in s2]
Count1 = [0 for i in range(0, 26)]
Count2 = [0 for i in range(0, 26)]
for x in ar1:
	Count1[x] = Count1[x] + 1
for x in ar2:
	Count2[x] = Count2[x] + 1
Deletions = 0
for i in range(0, 26):
	Deletions = Deletions + abs(Count1[i] - Count2[i])
print(Deletions)


from sys import stdin
line1 = stdin.readline().strip()
line2 = stdin.readline().strip()
counter = dict()
for letter in line1:
	if letter not in counter.keys():
		counter[letter] = 1
	else:
		counter[letter] += 1
for letter in line2:
	if letter not in counter.keys():
		counter[letter] = -1
	else:
		counter[letter] -= 1
print(sum([abs(x) for x in counter.values()]))


import sys
a = sys.stdin.readline().strip()
b = sys.stdin.readline().strip()
a_arr = sorted(a)
b_arr = sorted(b)
char_arr = sorted('abcdefghijklmnopqrstuvwxyz')
a_count_map = {}
b_count_map = {}
for c in char_arr:
	a_count_map[c] = 0
	b_count_map[c] = 0
for i in range(max(len(a_arr), len(b_arr))):
	if i < len(a_arr):
		key = a_arr[i]
		a_count_map[key] = a_count_map[key] + 1
	if i < len(b_arr):
		key = b_arr[i]
		b_count_map[key] = b_count_map[key] + 1
result = 0
for c in char_arr:
	result = result + abs(a_count_map[c] - b_count_map[c])
print(result)


import sys
OFFSET = 97
word1 = sys.stdin.readline().strip()
word2 = sys.stdin.readline().strip()
charList = [0] * 26
for c in word1:
	charList[ord(c) - OFFSET] += 1
for c in word2:
	charList[ord(c) - OFFSET] -= 1
changes = 0
for i in charList:
	changes += (i ** 2) ** 0.5
print(int(changes))


from collections import defaultdict
str1 = input()
str2 = input()
counts1 = defaultdict(int)
counts2 = defaultdict(int)
for char in str1:
	counts1[char] += 1
for char in str2:
	counts2[char] += 1
allkeys = set(list(counts1.keys()) + list(counts2.keys()))
print(sum((abs(counts1[key] - counts2[key]) for key in allkeys)))


from collections import Counter
a = Counter(input())
b = Counter(input())
print(sum((abs(a[ltr] - b[ltr]) for ltr in set(a) | set(b))))


line1 = input()
line2 = input()

def anagram(line1, line2):
	letters1 = [0] * 26
	letters2 = [0] * 26
	for c in line1:
		letters1[ord(c) - 97] += 1
	for c in line2:
		letters2[ord(c) - 97] += 1
	deletes = 0
	for i in range(26):
		if letters1[i] > letters2[i] or letters2[i] > letters1[i]:
			deletes += abs(letters1[i] - letters2[i])
	print(deletes)
anagram(line1, line2)


str1 = input()
str2 = input()
str1 = list(str1)
str2 = list(str2)
i = 0
while i < len(str1):
	element = str1[i]
	if element in str2:
		str1.remove(element)
		str2.remove(element)
		i = i - 1
	i = i + 1
ans1 = len(str1)
ans2 = len(str2)
print(ans1 + ans2)


from collections import Counter
string1 = str(input())
string2 = str(input())
c1 = Counter(string1)
c2 = Counter(string2)
deletions = 0
for e in c1:
	if e in c2:
		deletions += abs(c1[e] - c2[e])
	else:
		deletions += c1[e]
for e in c2:
	if not e in c1:
		deletions += c2[e]
print(deletions)


x = input()
y = input()
x_ = set(x)
y_ = set(y)
s = y_ ^ x_
ans = 0
for i in s:
	ans += x.count(i)
	ans += y.count(i)
s = x_ & y_
for i in s:
	ans += abs(x.count(i) - y.count(i))
print(ans)


__author__ = 'hadoop'
from sys import stdin
str1 = stdin.readline()
str2 = stdin.readline()
A = [0] * 26
B = [0] * 26
count = 0
len1 = len(str1)
len2 = len(str2)
for i in range(0, len1):
	if ord(str1[i]) > 96 and ord(str1[i]) < 123:
		A[ord(str1[i]) - 97] += 1
for i in range(0, len2):
	if ord(str2[i]) > 96 and ord(str2[i]) < 123:
		B[ord(str2[i]) - 97] += 1
for i in range(0, 26):
	count = count + abs(A[i] - B[i])
print(count)


s1 = input()
s2 = input()

def string_difference(string1, string2):
	sl1 = list(string1)
	sl2 = list(string2)
	sl1_len = len(sl1)
	to_remove = []
	i = 0
	while i < sl1_len:
		if sl1[i] in sl2:
			sl2.remove(sl1[i])
			sl1.remove(sl1[i])
			sl1_len -= 1
		else:
			i += 1
	return len(sl1) + len(sl2)
print(string_difference(s1, s2))


a = list(input())
b = list(input())
count = 0
a.sort()
b.sort()
i = j = 0
while i < len(a) and j < len(b):
	if a[i] == b[j]:
		i += 1
		j += 1
		continue
	if a[i] < b[j]:
		count += 1
		i += 1
		continue
	if a[i] > b[j]:
		count += 1
		j += 1
if i < len(a):
	count += len(a) - i
else:
	count += len(b) - j
print(count)


s1 = input()
s2 = input()
m = {}
for c in s1:
	if not c in m:
		m[c] = 1
	else:
		m[c] = m[c] + 1
for c in s2:
	if not c in m:
		m[c] = -1
	else:
		m[c] = m[c] - 1
total = 0
for (c, count) in m.items():
	total = total + abs(count)
print(total)


a = list(input())
b = list(input())
a = dict(((c, a.count(c)) for c in set(a)))
b = dict(((c, b.count(c)) for c in set(b)))
for (k, v) in b.items():
	a[k] = v if k not in a else a[k] - v
print(sum([abs(n) for n in a.values()]))


def getCount(list):
	count = []
	for i in range(26):
		count.append(0)
	for item in list:
		count[ord(item) - ord('a')] += 1
	return count
list1 = list(input())
list2 = list(input())
count1 = getCount(list1)
count2 = getCount(list2)
total = 0
for i in range(26):
	total += abs(count1[i] - count2[i])
print(total)


str1 = list(input())
str2 = list(input())
le = min(len(str2), len(str1))
count = 0
while str1:
	x = str1.pop()
	if x in str2:
		str2.remove(x)
	else:
		count += 1
count += len(str2)
print(count)


class MakeItAnagram:

	def getResult(self, string1, string2):
		dictString1 = dict()
		dictString2 = dict()
		for c in string1:
			if c not in dictString1.keys():
				dictString1[c] = 1
			else:
				dictString1[c] = dictString1[c] + 1
		for c in string2:
			if c not in dictString2.keys():
				dictString2[c] = 1
			else:
				dictString2[c] = dictString2[c] + 1
		number_chars_to_delete = 0
		for key in dictString1.keys():
			num_found1 = dictString1[key]
			if key not in dictString2.keys():
				diff = num_found1
				number_chars_to_delete += diff
			else:
				num_found2 = dictString2[key]
				if num_found1 > num_found2:
					diff = num_found1 - num_found2
					number_chars_to_delete += diff
		for key in dictString2.keys():
			num_found2 = dictString2[key]
			if key not in dictString1.keys():
				diff = num_found2
				number_chars_to_delete += diff
			else:
				num_found1 = dictString1[key]
				if num_found2 > num_found1:
					diff = num_found2 - num_found1
					number_chars_to_delete += diff
		return number_chars_to_delete
string1 = input()
string2 = input()
m = MakeItAnagram()
print(m.getResult(string1, string2))


A = sorted(list(input()))
B = sorted(list(input()))
count = 0
while len(A) and len(B):
	if A[0] == B[0]:
		A.pop(0)
		B.pop(0)
	elif A[0] < B[0]:
		A.pop(0)
		count += 1
	else:
		B.pop(0)
		count += 1
print(count + len(A) + len(B))


s1 = list(input())
s2 = list(input())
common = set(s1).intersection(set(s2))
for c in common:
	if c in s1 and c in s2:
		while c in s1 and c in s2:
			s1.remove(c)
			s2.remove(c)
deletions = len(s1) + len(s2)
print(deletions)


str1 = list(input())
str2 = list(input())
mp = {}
count = 0
for (index, c) in enumerate(str1):
	if c in mp:
		mp[c] += 1
	else:
		mp[c] = 1
for (index, c) in enumerate(str2):
	if c in mp:
		mp[c] -= 1
	else:
		mp[c] = -1
vals = map(abs, mp.values())
print(sum(vals))


STR1 = []
STR2 = []
string1 = list(input())
string2 = list(input())
x = len(string1) + len(string2)
string1_uniq = set(string1)
string2_uniq = set(string2)
STR1 = sorted(string1_uniq)
STR2 = sorted(string2_uniq)
flag = 0
for i in STR1:
	if string2.count(i) > 0:
		temp = min(string1.count(i), string2.count(i))
		flag += temp
	else:
		pass
print(x - flag * 2)


(s1, s2) = (sorted(input()), sorted(input()))
i = 0
j = 0
t = 0
while i < len(s1) and j < len(s2):
	if s1[i] == s2[j]:
		i += 1
		j += 1
	else:
		t += 1
		if s1[i] > s2[j]:
			j += 1
		else:
			i += 1
t += len(s1) - i
t += len(s2) - j
print(t)


x = [0] * 26
y = [0] * 26
s1 = input()
s2 = input()
for i in s1:
	x[ord(i) - ord('a')] += 1
for i in s2:
	y[ord(i) - ord('a')] += 1
count = 0
for i in range(26):
	if x[i] < y[i]:
		count = count + y[i] - x[i]
	else:
		count = count + x[i] - y[i]
print(count)


first = sorted(list(input('')))
firstList = sorted(list(first))
second = sorted(list(input('')))
secondList = sorted(list(second))
last_first = 0
last_second = 0
deletion = 0
for i in range(0, len(first)):
	if first[i] not in secondList:
		deletion += 1
	else:
		for x in range(last_second, len(second)):
			if secondList[x] == first[i]:
				secondList[x] = ''
				last_second = x
				break
for j in range(0, len(second)):
	if second[j] not in firstList:
		deletion += 1
	else:
		for y in range(last_first, len(first)):
			print
			if firstList[y] == second[j]:
				firstList[y] = ''
				last_first = y
				break
print(deletion)


f = sorted(input())
s = sorted(input())
df = {}
ds = {}
for i in f:
	if i not in df:
		df[i] = 1
	else:
		df[i] += 1
for i in s:
	if i not in ds:
		ds[i] = 1
	else:
		ds[i] += 1
sum = 0
for i in df:
	if i in ds:
		sum += abs(df[i] - ds[i])
		del ds[i]
	else:
		sum += df[i]
for i in ds:
	sum += ds[i]
print(sum)


string1 = input()
string2 = input()
charCount1 = [0] * 26
charCount2 = [0] * 26
numDeletions = 0
for i in string1:
	charCount1[ord(i) - 97] += 1
for i in string2:
	charCount2[ord(i) - 97] += 1
for i in range(0, 26):
	numDeletions += abs(charCount1[i] - charCount2[i])
print(numDeletions)


A = list(input())
B = list(input())
length1 = len(A)
length2 = len(B)
count = 0
for i in range(length1):
	length = len(B)
	j = 0
	while j < length:
		if A[i] == B[j]:
			B.remove(A[i])
			count = count + 1
			break
		else:
			j = j + 1
print(length1 - count + (length2 - count))