CF144C.Anagram Search

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A string tt is called an anagram of the string ss , if it is possible to rearrange letters in tt so that it is identical to the string ss . For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not.

The string tt is called a substring of the string ss if it can be read starting from some position in the string ss . For example, the string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba".

You are given a string ss , consisting of lowercase Latin letters and characters "?". You are also given a string pp , consisting of lowercase Latin letters only. Let's assume that a string is good if you can obtain an anagram of the string pp from it, replacing the "?" characters by Latin letters. Each "?" can be replaced by exactly one character of the Latin alphabet. For example, if the string pp = «aba», then the string "a??" is good, and the string «?bc» is not.

Your task is to find the number of good substrings of the string ss (identical substrings must be counted in the answer several times).

输入格式

The first line is non-empty string ss , consisting of no more than 10510^{5} lowercase Latin letters and characters "?". The second line is non-empty string pp , consisting of no more than 10510^{5} lowercase Latin letters. Please note that the length of the string pp can exceed the length of the string ss .

输出格式

Print the single number representing the number of good substrings of string ss .

Two substrings are considered different in their positions of occurrence are different. Thus, if some string occurs several times, then it should be counted the same number of times.

输入输出样例

  • 输入#1

    bb??x???
    aab
    

    输出#1

    2
    
  • 输入#2

    ab?c
    acb
    

    输出#2

    2
    

说明/提示

Consider the first sample test. Here the string ss has two good substrings: "b??" (after we replace the question marks we get "baa"), "???" (after we replace the question marks we get "baa").

Let's consider the second sample test. Here the string ss has two good substrings: "ab?" ("?" can be replaced by "c"), "b?c" ("?" can be replaced by "a").

首页