Codeforces Round 296 (Div. 1)
D
Fuzzy Search
Codeforces
2500
原题
← CE →
翻译中…

Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings consisting of letters 'A', 'T', 'G' and 'C'.

翻译中…

Let's consider the following scenario. There is a fragment of a human DNA chain, recorded as a string $*S*$. To analyze the fragment, you need to find all occurrences of string $*T*$ in a string $*S*$. However, the matter is complicated by the fact that the original chain fragment could contain minor mutations, which, however, complicate the task of finding a fragment. Leonid proposed the following approach to solve this problem.

翻译中…

Let's write down integer $*k* ≥ 0$ — the error threshold. We will say that string $*T*$ occurs in string $*S*$ on position $*i*$ ($1 ≤ *i* ≤ |*S*| - |*T*| + 1$), if after putting string $*T*$ along with this position, each character of string $*T*$ corresponds to the some character of the same value in string $*S*$ at the distance of at most $*k*$. More formally, for any $*j*$ ($1 ≤ *j* ≤ |*T*|$) there must exist such $*p*$ ($1 ≤ *p* ≤ |*S*|$), that $|(*i* + *j* - 1) - *p*| ≤ *k*$ and $*S*[*p*] = *T*[*j*]$.

翻译中…

For example, corresponding to the given definition, string "ACAT" occurs in string "AGCAATTCAT" in positions $2$, $3$ and $6$.

翻译中…

image

翻译中…

Note that at $*k* = 0$ the given definition transforms to a simple definition of the occurrence of a string in a string.

翻译中…

Help Leonid by calculating in how many positions the given string $*T*$ occurs in the given string $*S*$ with the given error threshold.

翻译中…

Input

翻译中…

The first line contains three integers $|*S*|, |*T*|, *k*$ ($1 ≤ |*T*| ≤ |*S*| ≤ 200 000$, $0 ≤ *k* ≤ 200 000$) — the lengths of strings $*S*$ and $*T*$ and the error threshold.

翻译中…

The second line contains string $*S*$.

翻译中…

The third line contains string $*T*$.

翻译中…

Both strings consist only of uppercase letters 'A', 'T', 'G' and 'C'.

翻译中…

Output

翻译中…

Print a single number — the number of occurrences of $*T*$ in $*S*$ with the error threshold $*k*$ by the given definition.

翻译中…

Note

翻译中…

If you happen to know about the structure of the human genome a little more than the author of the problem, and you are not impressed with Leonid's original approach, do not take everything described above seriously.

翻译中…

样例

Input #1
10 4 1
AGCAATTCAT
ACAT
Output #1
3
InputCopy OutputCopy
题目信息
题号
528D
时间限制
3 s
内存限制
256 MB
标签
位运算
暴力
FFT

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。