LogiQuest

117. Minimum Window Containing All

HardSliding Window

Print the length of the shortest substring of s that contains every character of t (with multiplicity), or 0 if none exists.

Input format

Line 1: s Line 2: t

Output format

The minimum length, or 0.

Example 1

Input

ADOBECODEBANC
ABC

Output

4

Example 2

Input

a
a

Output

1

Constraints

1 ≤ |s|, |t| ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…