#SDNU1260. Problem H. The chord

Problem H. The chord

Description

Now lmh has already written a new GTP, he know how to play the broken chord by right hand. But as for the left hand chords, he can’t play all chords.So after he gets a new chord by random number programme, he finds a problem-- he can’t sing this song because his ability is not enough. But GTP is written, he doesn’t want to give up. Can you tell him how long can he sing continuously?

lmh is foolish. Even if he grasps a rhythm, such as ABCDABCD, he only can play ABCDABCD fluently, BCBCBCBC or ABCDABCDABCDABCD he can’t play it fluently.But as for BCBC, he can play it and just ignore AA and DD.

The guitar have a lot of the left chords. lmh just knows part of it, including $C, Dm, Em, Am, F, G, D7, E, D, A, A7, Bm, B7, C7, G7, Dm7, Fmaj7, Asus4.$ This problem just need to deal with these chords.

Format

Input

Input contains multiple test cases. Each test case contains two strings, each string will have at most 100000100000 characters.First string means the rhythm which lmh has grasped. Second string means a new rhythm by lmh’s random programme.

Output

A number means the biggest length which lmh can play.

(If he can’t play, output 00).

Samples

CAmFG
CAmFGCAmFG
AGAsus4D
GAsus4
B7G7
B7G7B7G7B7G7
AmFmaj7C7Dm7C7
C7Dm7C7Dm7C7
4
2
2
3

Hints

对于第一个样例来说,可以花费0点气运买来一个B组成一个TTBT,所以最终气运为1-0=1。
对于第二个样例,可以花费0点和1点气运买一个B和一个T,组成TTBTTBT,所以最后花费为2 - 1 = 1。
对于第三个样例,可以花费0点气运买一个T,组成TTBTB,最后花费为1-0=1。