No.717 Commitment to Fashion
Problem Statement
Mr. A owns $N$ tops and $M$ bottoms, and each is either plain or patterned. Being a careless person, he throws away any piece of clothing once he has worn it.
However, he is very particular about fashion, and he will only wear clothes if the top and bottom are both plain or both patterned.
Given the integers $N$,$M$ and the strings $S$,$T$ describing the clothes he owns, output the number of days he can wear clothes.
Input
N M S T
He owns $N$ tops, whose patterns are given by the string $S$. Similarly, he owns $M$ bottoms, whose patterns are given by the string $T$.
In the strings $S$,$T$, "A" denotes plain and "B" denotes patterned.
$1 \le N,M \le 10000$
$|S|=N$
$|T|=M$
Output
Output the number of days he can wear clothes. Print a newline at the end.
Sample
Sample 1
Input
5 5 AABAB BAABB
Output
4
He can dress in patterned top and bottom for 2 days and in plain top and bottom for 2 days, but on the 5th day, what remains is a plain top and a patterned bottom, so he cannot dress.
Sample 2
Input
5 5 AAAAA BBBBB
Output
0
No matter what he does, he cannot wear a top and bottom of the same type.
Sample 3
Input
10 8 BBBAABABBB BABABABA
Output
7
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
gotutiyan