Time limit
2s
Memory limit
128 MB
A string made only of the characters A and B is called a Shomtring if it satisfies all of the following conditions.
countA characters A.countB characters B.A has length at most maxA.B has length at most maxB.Given countA, countB, maxA, and maxB, find the maximum possible length of a Shomtring.
The first line contains four integers countA, countB, maxA, and maxB. Each value is between 0 and 1,000,000, inclusive.
Print the maximum possible length of a Shomtring.