Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/string-umumiy-harflar

Number of common letters

Easy 1000 ms 128 MB 30%
Share

Two words $a$ and $b$ of lowercase Latin letters are given. For every letter take the smaller of its counts in $a$ and in $b$. Find the sum of these numbers over all letters.

Counting the equal letters of two words in pairs

Input

The first line contains $a$, the second line $b$.

Output

One integer.

Note

$1 \le |a|, |b| \le 10^{5}$
$a$ and $b$ consist of lowercase Latin letters only

Examples

Input #1
banana
ananas
Output #1
5
Input #2
abc
xyz
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.