Input
aba
baobababbah
Output
2
Input
mars
sunvenusearthmarsjupitersaturnuranusneptune
Output
0