AT_abc438_b [ABC438B] Substring 2

Description

You are given integers $ N $ and $ M $ , a digit string $ S $ of length $ N $ , and a digit string $ T $ of length $ M $ . Here, a digit string is a string consisting of digits from `0` to `9`. You can perform the following operation zero or more times: - Choose one character from $ T $ and increase the chosen digit by $ 1 $ . However, if the chosen digit is `9`, change it to `0`. Find the minimum number of operations required to make $ T $ a substring (**contiguous** subsequence) of $ S $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ M $ $ S $ $ T $

Output Format

Output the minimum number of operations required to make $ T $ a substring of $ S $ .

Explanation/Hint

### Sample Explanation 1 You can make $ T $ a substring of $ S $ with two operations as follows: - Perform the operation on the $ 2 $ nd character of $ T $ . $ T= $ `91` becomes $ T= $ `92`. - Perform the operation on the $ 1 $ st character of $ T $ . $ T= $ `92` becomes $ T= $ `02`. `02` is a substring from the $ 2 $ nd character to the $ 3 $ rd character of $ S $ . It is impossible to make $ T $ a substring of $ S $ with less than two operations, so output $ 2 $ . ### Sample Explanation 2 `38` is a substring of `438` from the beginning. Thus, output $ 0 $ . ### Constraints - $ 1\le M\le N\le 100 $ - $ N $ and $ M $ are integers. - $ S $ is a digit string of length $ N $ . - $ T $ is a digit string of length $ M $ .