#D8252. AABABCAC
AABABCAC
AABABCAC
Problem
Given the strings , . First, let the string set {}, . At this time, I want to perform the following operations as much as possible.
operation
step1
Perform the following processing for all .
-
From all subsequences of (not necessarily contiguous), choose any one that is equal to . Let the indexes corresponding to of the selected subsequence be , ,…, (however, 1 … ). If there is no such subsequence, the operation ends.
-
Divide the original string with the selected substring characters , ,…, and convert them to to add.
For example, in the case of "abcdcd" and "ac", the following two division methods can be considered. If you choose the first and third characters of , it will be split into "", "b" and "dcd". If you choose the first and fifth characters of , it will be split into "", "bcd" and "d".
step2
Replace with and empty . Increase the number of operations by 1.
Subsequence example
The subsequences of "abac" are {"", "a", "b", "c", "aa", "ab", "ac", "ba", "bc", "aac", "aba" "," abc "," bac "," abac "}. "a" is a subsequence created by extracting the first or third character of "abac". "ac" is a subsequence created by extracting the 1st and 4th characters of "abac" or the 3rd and 4th characters.
Constraints
The input satisfies the following conditions.
- 1
- Characters contained in the strings and are uppercase or lowercase letters of the alphabet
Input
The input is given in the following format.
The string is given on the first line, and the string is given on the second line.
Output
Output the maximum number of operations.
Examples
Input
AABABCAC A
Output
2
Input
abaabbabaabaabbabbabaabbab ab
Output
3
Input
AbCdEfG aBcDeFg
Output
0
inputFormat
input satisfies the following conditions.
- 1
- Characters contained in the strings and are uppercase or lowercase letters of the alphabet
Input
The input is given in the following format.
The string is given on the first line, and the string is given on the second line.
outputFormat
Output
Output the maximum number of operations.
Examples
Input
AABABCAC A
Output
2
Input
abaabbabaabaabbabbabaabbab ab
Output
3
Input
AbCdEfG aBcDeFg
Output
0
样例
abaabbabaabaabbabbabaabbab
ab
3