P10442 "MYOI-R3" String

Description

Given strings $s, t$. Now you need to delete some characters in $s, t$ and reorder the remaining characters so that $s = t$. What is the maximum possible value of $|s|$ (i.e., the length of string $s$) after the operations?

Input Format

The first line contains a string $s$. The second line contains a string $t$.

Output Format

Output one integer in one line, representing the maximum possible value of $|s|$ after the operations.

Explanation/Hint

In the first sample, delete `a` and keep `bc`. Then $|s| = 2$, and it can be proven that this is optimal. In the second sample, delete `aaaaa` and keep the empty string. Delete `bbbbb` and keep the empty string. Then $|s| = 0$, and it can be proven that this is optimal. **This problem uses bundled testdata**. Let $n = \max(|s|, |t|)$. | $\text{Subtask}$ | $n \le$ | Special Property | Total Score | | :--------------: | :-----: | :--------------: | :---------: | | $1$ | $10$ | None | $25$ | | $2$ | $10^5$ | $\text{A}$ | $25$ | | $3$ | $10^5$ | $\text{B}$ | $25$ | | $4$ | $10^5$ | None | $25$ | Constraints: For $100\%$ of the data, $1 \le |s|, |t| \le 10^5$. Both strings consist of lowercase letters. Special Property $\text{A}$: $s$ is a permutation of $\text{a} \sim \text{z}$. Special Property $\text{B}$: It is guaranteed that $s_i, t_i \in \{\text{a}, \text{b}\}$. Translated by ChatGPT 5