~/algor $ cat problems/ikki-korsatkich-anagramma-orinlari
Anagrams in a text
Medium
1000 ms
128 MB
64%
Two strings $s$ and $p$ are given. How many segments of $|p|$ consecutive letters of $s$ are anagrams of $p$ (made of the same letters in the same quantities, possibly in a different order)? Segments starting at different positions are counted separately.
Input
The first line contains $s$, the second line contains $p$.
Output
One integer — the number of anagram segments.
Note
$1 \le |s|, |p| \le 10^{5}$
the strings consist of lowercase Latin letters
Examples
Input #1
cbaebabacd abc
Output #1
2
Input #2
ab abc
Output #2
0