#P3763. Gene Sequence Matching

    ID: 17013 Type: Default 1000ms 256MiB

Gene Sequence Matching

Gene Sequence Matching

At Garyton University's Institute of Biological Research, a gene sequence SS was discovered that determines whether a person likes lotus root. An individual carrying this gene exhibits a fondness for lotus root; however, researchers found that any modification of at most 33 nucleotides in SS still results in the lotus root preference. Given a person's DNA sequence S0S_0 (which displays the lotus root liking trait), count the number of contiguous substrings of S0S_0 that can be transformed into SS by modifying at most 33 nucleotides.

The mathematical condition is: For each contiguous substring TT of S0S_0 with T=S|T|=|S|, if the Hamming distance between TT and SS satisfies $$d_H(T,S) \leq 3,$$ then TT is a candidate gene location.

inputFormat

The input consists of two lines:

  • The first line contains the DNA sequence $S_0$ of a person displaying the trait.
  • The second line contains the gene sequence $S$.
It is guaranteed that $|S_0| \geq |S|$, and both sequences consist only of the characters A, C, G, and T.

outputFormat

Output a single integer representing the count of contiguous substrings of S0S_0 (of length equal to S|S|) that can be transformed into SS by modifying at most 33 nucleotides (i.e. having a Hamming distance of at most 33 from SS).

sample

ACGT
ACG
2