406069: GYM102254 B Building Bridges

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Building Bridgestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Like happens every year, the students from the first year of IME (Institute of Meticulous Edifices) are in the military training camp and one of the activities is to cross a river.

Normal students would cross the river swimming, but not the IME students! Each student's squad will have to build one bridge from one riverside to the other, but there's a catch, on each riverside there are areas reserved for each squad and the squads can only build a bridge starting and ending on areas reserved to that squad. Also the bridges are very weak, so they can't cross each other, including on riversides.

Before starting the activity, Lieutenant Lacoste asks for the Sheriff Sereno what's the maximum number of bridges that can be built, so he can divide the tasks equally.

Sheriff Sereno is too worried in maintaining the marking tapes untouchable to answer this question quickly, so he asks you (who was occasionally passing by) to calculate the answer.

Input

The first line of input contains two lowercase English strings, $$$a$$$ and $$$b$$$ ($$$1 \le |a|, |b| \le 10^3$$$) — the areas reserved in each riverside. The $$$i$$$-th letter from string $$$a$$$ indicates that the area $$$i$$$ belongs to squad $$$a_i$$$, same goes for $$$b$$$.

Output

Print the maximum number of bridges that can be built.

ExamplesInput
abacaba aba
Output
3
Input
aadodbcecoeo dcceoafas
Output
5

加入题单

算法标签: