#C9429. Anagram Substring Count

    ID: 53521 Type: Default 1000ms 256MiB

Anagram Substring Count

Anagram Substring Count

You are given two strings (s) and (t). Your task is to count the number of substrings in (s) that are anagrams of (t). A substring of (s) is said to be an anagram of (t) if it contains exactly the same characters with the same multiplicities as in (t), but possibly in a different order.

For example, if (s = \texttt{forfinef}) and (t = \texttt{fine}), the substrings (\texttt{forf}) and (\texttt{fine}) should be considered (after reordering) and the answer would be (2).

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains the string (s).
  • The second line contains the string (t).

outputFormat

Output a single integer to standard output (stdout), which represents the number of substrings in (s) that are anagrams of (t).## sample

forfinef
fine
2