cswork / OAOpen practice workspace

AmazonOA #343

Similar Text Substring Count

Estimated EasyJudge-ready

Topics (AI-labelled)Strings

Count the contiguous fragments of content whose length equals that of target and that become equal to target either with no swap or after swapping one pair of adjacent characters inside the fragment. Fragments with different start positions are counted separately.

Input

Two lines of input: target, then content. Original bounds: both consist of lowercase letters, 1≤|target|≤|content|≤50.

Output

Output a single integer, the answer.

Example 1

Input:

moon
monomon

Output:

2

Example 2

Input:

aaa
aaaa

Output:

2

Example 3

Input:

abc
acbabc

Output:

2

Example notes

In the first example the valid windows are mono at start 0 and omon at start 3, fixed by swapping the last two and the first two characters respectively; the answer is 2. The onom in the source explanation is not the corresponding window.

Editorial

Loading solution…