Gnimmah distance - MarisaOJ: Marisa Online Judge

Gnimmah distance

Time limit: 1000 ms
Memory limit: 256 MB
The Gnimmah distance between two strings $s$ and $t$ of equal length is the number of positions at which the corresponding characters are similar. For example, string `abc` and `aba` have the Gnimmah distance of 2 as the first and the second characters of 2 string are equal. Given 2 strings $A, B$ and $A$ is always longer than $B$. Calculate the sum of Gnimmah distance between $B$ and each substring of length $|B|$ of $A$. ### Input - The first line is string $A$. - The second line is string $B$. ### Output - Print an integer, the sum of Gnimmah distance between each substring of length $|B|$ of $A$, and $B$. ### Constraints - $1 \le |A|, |B| \le 10^5$. - Both strings only consist of lowercase English letters. ### Example Input: ``` aaba abc ``` Output: ``` 3 ```